/* =============================================
   NEXASYS SAAS - DESIGN SYSTEM
   Padrão visual unificado para todas as páginas
   ============================================= */

/* Fonte carregada via <link> no HTML para evitar bloqueio */

:root {
    /* Cores principais - Gravity Pastel Palette */
    --primary: #5b7fa6;
    --primary-dark: #476a8e;
    --primary-light: #8babc8;
    --primary-50: #e8edf3;
    
    /* Acento */
    --accent: #7ea8cb;
    --accent-dark: #5b7fa6;
    --accent-light: #a8c8e8;
    
    /* Cores de feedback */
    --success: #7bc8a4;
    --success-light: #d8f0e3;
    --warning: #e2c17b;
    --warning-light: #f5efd6;
    --danger: #d48b8b;
    --danger-light: #f5e6e6;
    --info: #7ea8cb;
    --info-light: #dce8f5;
    
    /* Cores neutras */
    --white: #FFFFFF;
    --dark: #2c3a4b;
    --gray: #6b7d8f;
    --gray-50: #f5f7fb;
    --gray-100: #edf1f7;
    --gray-200: #dce3ec;
    --gray-300: #c4ced8;
    --gray-400: #a0adb8;
    --gray-500: #6b7d8f;
    --gray-600: #4a5a6b;
    --gray-700: #3b4a5e;
    --gray-800: #2c3a4b;
    --gray-900: #1e2a38;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Bordas */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

/* ===== DARK MODE (Premium) ===== */
[data-theme="dark"] {
    --primary: #7ea8cb;
    --primary-dark: #5b8fb5;
    --primary-light: #a8c8e8;
    --primary-50: #1e2d3d;
    
    --accent: #7ea8cb;
    --accent-dark: #5b8fb5;
    --accent-light: #a8c8e8;
    
    --success: #34d399;
    --success-light: #064e3b;
    --warning: #fbbf24;
    --warning-light: #78350f;
    --danger: #f87171;
    --danger-light: #7f1d1d;
    --info: #60a5fa;
    --info-light: #1e3a5f;
    
    --white: #1a1a2e;
    --dark: #e2e8f0;
    --gray: #94a3b8;
    --gray-50: #1e2433;
    --gray-100: #252d3d;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

[data-theme="dark"] body {
    background: #0f1219;
    color: #e2e8f0;
}

[data-theme="dark"] .header {
    background: linear-gradient(135deg, #1a2332 0%, #243447 40%, #2d4a66 100%);
}

[data-theme="dark"] .nav-links a {
    background: #1e2433;
    border-color: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .nav-links a:hover {
    background: #252d3d;
    border-color: #7ea8cb;
    color: #7ea8cb;
}

[data-theme="dark"] .nav-links a.active {
    background: #2d4a66;
    color: white;
    border-color: #2d4a66;
}

[data-theme="dark"] .card {
    background: #1a2030;
    border-color: #2a3545;
}

[data-theme="dark"] .card-header {
    border-color: #2a3545;
}

[data-theme="dark"] .stat-card {
    background: #1a2030;
    border-color: #2a3545;
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
    background: #1a2030;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
    background: #1e2433;
    border-color: #7ea8cb;
    box-shadow: 0 0 0 3px rgba(126, 168, 203, 0.2);
}

[data-theme="dark"] .form-input::placeholder,
[data-theme="dark"] .form-textarea::placeholder {
    color: #64748b;
}

[data-theme="dark"] .modal {
    background: #1a2030;
}

[data-theme="dark"] .modal-header {
    border-color: #2a3545;
}

[data-theme="dark"] .tabs {
    background: #1a2030;
}

[data-theme="dark"] .tab.active {
    background: #252d3d;
    color: #7ea8cb;
}

[data-theme="dark"] .table th {
    background: #1e2433;
    color: #94a3b8;
}

[data-theme="dark"] .table td {
    color: #cbd5e1;
}

[data-theme="dark"] .table th,
[data-theme="dark"] .table td {
    border-color: #2a3545;
}

[data-theme="dark"] .table tr:hover {
    background: #1e2433;
}

[data-theme="dark"] .btn-secondary {
    background: #252d3d;
    color: #cbd5e1;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #334155;
}

[data-theme="dark"] .alert-success { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .alert-error { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #78350f; color: #fde68a; border-color: #92400e; }
[data-theme="dark"] .alert-info { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }

[data-theme="dark"] .badge-success { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-danger { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-warning { background: #78350f; color: #fde68a; }
[data-theme="dark"] .badge-info { background: #1e3a5f; color: #93c5fd; }

/* Dark mode toggle button */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.theme-toggle:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.05);
}
.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}
.theme-toggle:hover svg {
    transform: rotate(15deg);
}

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

/* Base */
body {
    font-family: var(--tenant-font, 'Inter'), -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fb;
    min-height: 100vh;
    color: #3b4a5e;
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, #3b4f6b 0%, #4a6585 40%, #5b7fa6 100%);
    color: white;
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-icon svg {
    width: 28px;
    height: 28px;
    stroke: white;
}

.header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header .subtitle {
    font-size: 14px;
    opacity: 0.85;
    font-weight: 500;
}

/* Container */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

.container-sm {
    max-width: 600px;
}

.container-md {
    max-width: 900px;
}

/* Navigation */
.nav-links {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--gray-600);
    text-decoration: none;
    padding: 10px 18px;
    border-radius: var(--radius);
    background: white;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.nav-links a:hover {
    background: var(--gray-50);
    border-color: var(--primary-light);
    color: var(--primary);
}

.nav-links a.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-links a svg {
    width: 18px;
    height: 18px;
}

/* Cards */
.card {
    background: #FFFFFF;
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--gray-100);
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon svg {
    width: 22px;
    height: 22px;
}

.card-icon.purple { background: linear-gradient(135deg, #dce8f5 0%, #c8d8eb 100%); }
.card-icon.purple svg { stroke: #5b7fa6; }

.card-icon.green { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); }
.card-icon.green svg { stroke: #059669; }

.card-icon.blue { background: linear-gradient(135deg, #dce8f5 0%, #c8d8eb 100%); }
.card-icon.blue svg { stroke: #476a8e; }

.card-icon.amber { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); }
.card-icon.amber svg { stroke: #d97706; }

.card-icon.pink { background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); }
.card-icon.pink svg { stroke: #db2777; }

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-outline:hover {
    background: var(--accent);
    color: #1C1C1C;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #FFFFFF;
    color: var(--gray-700);
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 127, 166, 0.15);
    background: #FFFFFF;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: var(--gray-50);
}

.table td {
    font-size: 14px;
    color: var(--gray-700);
}

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

.stat-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.stat-card .stat-icon svg {
    width: 26px;
    height: 26px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-light);
    color: #065f46;
}

.badge-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.badge-warning {
    background: var(--warning-light);
    color: #92400e;
}

.badge-info {
    background: var(--info-light);
    color: #1e40af;
}

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

.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--gray-500);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab:hover {
    color: var(--gray-800);
}

.tab.active {
    background: #FFFFFF;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab svg {
    width: 18px;
    height: 18px;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-600);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 16px;
        flex-direction: column;
        gap: 12px;
    }
    
    .container {
        padding: 16px;
    }
    
    .nav-links {
        flex-direction: column;
    }
    
    .nav-links a {
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tabs .tab {
        flex: 1 1 45%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.grid { display: grid; }
.hidden { display: none; }

/* Transição suave entre páginas */
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
body {
    animation: pageFadeIn 0.3s ease-out;
}
body.page-exit {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease-in, transform 0.2s ease-in;
}
