/* SOS Točka — Dashboard CSS */

:root {
    --color-primary:      #F3681B;
    --color-primary-dark: #D4540E;
    --color-dark:         #1A1A1A;
    --color-sidebar:      #23262D;
    --color-sidebar-hover:#2D3139;
    --color-light:        #F5F5F0;
    --color-white:        #FFFFFF;
    --color-gray-100:     #F4F4F4;
    --color-gray-200:     #E8E8E4;
    --color-gray-400:     #AAAAAA;
    --color-gray-600:     #666666;
    --color-success:      #27AE60;
    --color-danger:       #E74C3C;
    --color-warning:      #F39C12;
    --color-info:         #2980B9;

    --font-base:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --radius:       6px;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:    0 4px 20px rgba(0,0,0,0.12);
    --sidebar-w:    240px;
    --header-h:     60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font-base);
    color: var(--color-dark);
    background: var(--color-gray-100);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* -------------------------------------------------------
   Layout: sidebar + main
------------------------------------------------------- */
.dash-layout {
    display: flex;
    min-height: 100vh;
}

/* -------------------------------------------------------
   Sidebar
------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-sidebar);
    color: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    text-decoration: none;
}
.sidebar-logo img { width: 34px; height: 34px; }
.sidebar-logo__text {
    color: var(--color-white);
    font-weight: 800;
    font-size: 1.05rem;
}
.sidebar-logo__text span { color: var(--color-primary); }

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}
.sidebar-nav__section {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-white);
    text-decoration: none;
}
.sidebar-nav a.active {
    background: rgba(243,104,27,0.15);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}
.sidebar-nav .icon { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.07);
    font-size: 0.82rem;
}
.sidebar-user__name {
    font-weight: 700;
    color: var(--color-white);
    margin-bottom: 0.15rem;
}
.sidebar-user__role {
    color: rgba(255,255,255,0.45);
    font-size: 0.75rem;
}
.sidebar-user__links {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.75rem;
}
.sidebar-user__links a {
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    transition: background 0.15s, border-color 0.15s;
}
.sidebar-user__links a:hover {
    color: var(--color-white);
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.4);
    text-decoration: none;
}
.sidebar-version {
    padding: 0.5rem 1.25rem;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.25);
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* -------------------------------------------------------
   Main content area
------------------------------------------------------- */
.dash-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dash-header {
    height: var(--header-h);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 40;
}
.dash-header__title {
    font-weight: 700;
    font-size: 1.05rem;
    flex: 1;
}
.dash-header__actions { display: flex; gap: 0.5rem; align-items: center; }

.dash-content {
    flex: 1;
    padding: 1.75rem;
}

/* -------------------------------------------------------
   Page header
------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; }
.page-header p  { color: var(--color-gray-600); font-size: 0.9rem; margin-top: 0.25rem; }
.page-header__actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* -------------------------------------------------------
   Cards
------------------------------------------------------- */
.card {
    background: var(--color-white);
    border-radius: 8px;
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 700;
}
.card-body  { padding: 1.25rem; }
.card-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--color-gray-200);
    background: var(--color-gray-100);
    font-size: 0.85rem;
}

/* -------------------------------------------------------
   Tables
------------------------------------------------------- */
.table-responsive { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
thead th {
    background: var(--color-gray-100);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-gray-600);
    padding: 0.7rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--color-gray-200);
}
tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--color-gray-200);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-gray-100); }

/* -------------------------------------------------------
   Badges / Status
------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-success  { background: #d4edda; color: #155724; }
.badge-danger   { background: #f8d7da; color: #721c24; }
.badge-warning  { background: #fff3cd; color: #856404; }
.badge-info     { background: #d1ecf1; color: #0c5460; }
.badge-secondary{ background: var(--color-gray-200); color: var(--color-gray-600); }
.badge-primary  { background: rgba(243,104,27,0.15); color: var(--color-primary-dark); }

/* -------------------------------------------------------
   Buttons
------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    border: none;
    text-align: center;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn-primary   { background: var(--color-primary); color: var(--color-white) !important; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-gray-200); color: var(--color-dark) !important; }
.btn-secondary:hover { background: #ddd; }

.btn-danger    { background: var(--color-danger); color: var(--color-white) !important; }
.btn-danger:hover { background: #c0392b; }

.btn-success   { background: var(--color-success); color: var(--color-white) !important; }
.btn-success:hover { background: #1e8449; }

.btn-outline   { background: transparent; border: 1.5px solid var(--color-gray-400); color: var(--color-dark) !important; }
.btn-outline:hover { border-color: var(--color-dark); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* -------------------------------------------------------
   Tabs
------------------------------------------------------- */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tab-link {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-dark) !important;
    text-decoration: none !important;
    background: var(--color-white);
    border: 1.5px solid var(--color-gray-200);
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    cursor: pointer;
}
.tab-link:hover {
    border-color: var(--color-gray-400);
    background: var(--color-gray-100);
    text-decoration: none !important;
}
.tab-link.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white) !important;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(243,104,27,0.25);
}

/* -------------------------------------------------------
   Forms
------------------------------------------------------- */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: var(--color-dark);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1.5px solid var(--color-gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-base);
    color: var(--color-dark);
    background: var(--color-white);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(243,104,27,0.12);
}
.form-group input.is-invalid,
.form-group textarea.is-invalid,
.form-group select.is-invalid {
    border-color: var(--color-danger);
}
.form-group .help-text { font-size: 0.78rem; color: var(--color-gray-600); margin-top: 0.25rem; }
.form-group .error-text { font-size: 0.78rem; color: var(--color-danger); margin-top: 0.25rem; }
.form-group textarea    { resize: vertical; min-height: 100px; }

.form-group--consent { margin-top: 1.4rem; }
.consent-label {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-gray-700);
    line-height: 1.5;
    font-weight: normal;
}
.consent-label input[type="checkbox"] {
    margin-top: 0.2rem;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    accent-color: var(--color-primary);
}
.consent-label a { color: var(--color-primary); text-decoration: underline; }
.consent-label a:hover { color: var(--color-primary-dark, #c25510); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* -------------------------------------------------------
   Alerts
------------------------------------------------------- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.alert-success  { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning  { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info     { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* -------------------------------------------------------
   Toast notifications
------------------------------------------------------- */
#toast-container {
    position: fixed;
    top: 1.1rem;
    right: 1.1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 240px;
    max-width: 360px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    pointer-events: all;
    opacity: 0;
    transform: translateX(1.5rem);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.toast-in {
    opacity: 1;
    transform: translateX(0);
}
.toast.toast-out {
    opacity: 0;
    transform: translateX(1.5rem);
}
.toast-success {
    background: #1a7a3c;
    color: #fff;
    border: 1px solid #166432;
}
.toast-danger {
    background: #c0392b;
    color: #fff;
    border: 1px solid #a93226;
}
.toast__icon { font-size: 1rem; flex-shrink: 0; }
.toast__msg  { flex: 1; }
.toast__close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0 0 0.25rem;
    flex-shrink: 0;
}
.toast__close:hover { opacity: 1; }

/* -------------------------------------------------------
   Auth pages (login, register, etc.)
------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-dark) 0%, #2a1a10 100%);
    padding: 2rem 1rem;
}
.auth-card {
    background: var(--color-white);
    border-radius: 12px;
    padding: 2.25rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.auth-card .logo-wrap {
    text-align: center;
    margin-bottom: 1.75rem;
}
.auth-card .logo-wrap img { width: 52px; height: 52px; margin: 0 auto 0.75rem; }
.auth-card .logo-wrap h1 { font-size: 1.5rem; }
.auth-card .logo-wrap p  { color: var(--color-gray-600); font-size: 0.88rem; margin: 0.25rem 0 0; }
.auth-card h2 { font-size: 1.2rem; margin-bottom: 1.25rem; }
.auth-footer-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--color-gray-600);
}
.auth-divider {
    text-align: center;
    color: var(--color-gray-400);
    font-size: 0.8rem;
    margin: 1rem 0;
    position: relative;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--color-gray-200);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* -------------------------------------------------------
   Device detail
------------------------------------------------------- */
.device-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.device-meta__item { }
.device-meta__label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-gray-600);
    margin-bottom: 0.15rem;
}
.device-meta__value { font-weight: 600; font-size: 0.95rem; }

#map { height: 300px; border-radius: 8px; }

/* -------------------------------------------------------
   Pagination
------------------------------------------------------- */
.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid var(--color-gray-200);
    color: var(--color-dark);
    transition: background 0.15s;
}
.pagination a:hover { background: var(--color-gray-100); text-decoration: none; }
.pagination span.current {
    background: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}
.pagination span.disabled { color: var(--color-gray-400); cursor: not-allowed; }

/* -------------------------------------------------------
   Stats row
------------------------------------------------------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--color-white);
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
}
.stat-card__label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-gray-600);
    margin-bottom: 0.4rem;
}
.stat-card__value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-dark);
    line-height: 1;
}
.stat-card__sub { font-size: 0.8rem; color: var(--color-gray-400); margin-top: 0.25rem; }

/* -------------------------------------------------------
   Sortable table headers
------------------------------------------------------- */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--color-gray-600);
    text-decoration: none;
    font-weight: 600;
    font-size: inherit;
    white-space: nowrap;
    transition: color 0.15s;
}
.sort-link:hover { color: var(--color-primary); }
.sort-link--active { color: var(--color-primary); }

/* -------------------------------------------------------
   Recent events inline list
------------------------------------------------------- */
.recent-events-cell { min-width: 280px; max-width: 420px; }
.recent-events-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.recent-events-list__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--color-gray-100);
}
.recent-events-list__item:last-child { border-bottom: none; }
.recent-events-list__time {
    color: var(--color-gray-400);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.recent-events-list__body {
    color: var(--color-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.recent-events-list__link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}
.recent-events-list__link:hover { text-decoration: underline; }

/* -------------------------------------------------------
   Responsive
------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
    .sidebar.open { transform: translateX(0); }
    .dash-main { margin-left: 0; }
    .form-row  { grid-template-columns: 1fr; }
    .dash-content { padding: 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
