/* ═══════════════════════════════════════════════════════
 * VideoDriverORS Portal — Design System
 * Version: 1.0.0
 * Developed by Orbitand SAS
 * ═══════════════════════════════════════════════════════ */

/* ─── CSS Custom Properties ─────────────────────────── */
:root {
    /* Colors - Light Theme (Orbitand SAS) */
    --bg-primary: #f8fafc;
    --bg-secondary: rgba(255, 255, 255, 0.75);
    --bg-card: rgba(255, 255, 255, 0.65);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --bg-input: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.75);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-accent: #1A7875;

    --accent-primary: #1A7875; /* Orbitand Principal */
    --accent-primary-hover: #135d5a;
    --accent-secondary: #562A75; /* Orbitand Secundario */
    --accent-tertiary: #29234A; /* Orbitand Complementario */
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-danger-hover: #dc2626;

    --border-subtle: rgba(255, 255, 255, 0.4);
    --border-medium: rgba(26, 120, 117, 0.15);
    --border-focus: rgba(26, 120, 117, 0.4);

    --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 24px rgba(26, 120, 117, 0.15);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    /* Transitions */
    --transition-fast: 200ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 400ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Reset & Base ──────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(26, 120, 117, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(86, 42, 117, 0.08), transparent 25%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    letter-spacing: -0.01em; /* Kinetic Typography base */
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-primary-hover);
}

/* ─── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ─── Login Page ────────────────────────────────────── */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(26, 120, 117, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(86, 42, 117, 0.06) 0%, transparent 50%);
    padding: 20px;
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-logo .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Form Elements ─────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%238b92a8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* ─── Password Toggle ───────────────────────────────── */
.password-wrapper {
    position: relative;
}

.password-wrapper .form-control {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--accent-primary);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* ─── Buttons ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 2px 8px rgba(26, 120, 117, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: var(--accent-danger-hover);
}

.btn-success {
    background: var(--accent-success);
    color: var(--bg-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    color: var(--accent-primary);
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-sm);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ─── Dashboard Layout ──────────────────────────────── */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header .role-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 50px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: rgba(26, 120, 117, 0.12);
    color: var(--accent-primary);
    font-weight: 600;
}

.nav-item .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer .version-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* ─── Page Header ───────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header .header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ─── Stats Cards (Bento Grid) ───────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-4px) scale(1.01);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-value.accent {
    color: var(--accent-primary);
}

/* ─── Data Table ────────────────────────────────────── */
.table-container {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
}

tbody td {
    padding: 14px 20px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    vertical-align: middle;
}

tbody tr {
    transition: all var(--transition-fast);
}

tbody tr:hover {
    background: rgba(26, 120, 117, 0.06);
    transform: scale(1.002);
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ─── Status Badges ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active {
    background: rgba(52, 211, 153, 0.12);
    color: var(--accent-success);
}

.badge-inactive {
    background: rgba(248, 113, 113, 0.12);
    color: var(--accent-danger);
}

.badge-brand {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

/* ─── Dot indicator ─────────────────────────────────── */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-active {
    background: var(--accent-success);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.dot-inactive {
    background: var(--accent-danger);
    box-shadow: 0 0 6px rgba(248, 113, 113, 0.5);
}

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: scale(0.95);
    transition: transform var(--transition-fast);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
}

/* ─── RTSP URL Display ──────────────────────────────── */
.url-box {
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-secondary);
    word-break: break-all;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.url-box:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.url-box .copy-hint {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
}

/* ─── Toast Notifications ───────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 420px;
}

.toast-success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: var(--accent-success);
}

.toast-error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--accent-danger);
}

.toast-info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent-primary);
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ─── Empty State ───────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* ─── Loading Skeleton ──────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-row {
    height: 48px;
    margin-bottom: 8px;
}

/* ─── Credential Cards ──────────────────────────────── */
.cred-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.cred-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.cred-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: translateY(-2px);
}

.cred-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cred-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
}

.cred-card .cred-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
}

.cred-card .cred-field:last-child {
    border-bottom: none;
}

.cred-card .cred-field .field-label {
    color: var(--text-muted);
}

.cred-card .cred-field .field-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ─── Actions Dropdown ──────────────────────────────── */
.actions-cell {
    display: flex;
    gap: 6px;
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cred-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }
}
