/* ================================================
   CORIAL Hub - Shared Design System
   Brand Colors & Typography
   ================================================ */

:root {
    /* Primary Brand Colors */
    --corial-berry: #791812;
    --corial-berry-dark: #5a110d;
    --corial-berry-light: rgba(121, 24, 18, 0.08);
    --corial-berry-lighter: rgba(121, 24, 18, 0.04);
    
    /* Background Colors */
    --corial-eggshell: #FAF8F5;
    --corial-cream: #F5F2ED;
    --corial-white: #FFFFFF;
    
    /* Text Colors */
    --corial-text-primary: #1a1a1a;
    --corial-text-secondary: #4a4a4a;
    --corial-text-muted: #6b6b6b;
    --corial-text-light: #9a9a9a;
    
    /* Accent Colors */
    --corial-success: #166534;
    --corial-success-bg: #dcfce7;
    --corial-warning: #92400e;
    --corial-warning-bg: #fef3c7;
    --corial-info: #1e40af;
    --corial-info-bg: #dbeafe;
    --corial-error: #dc2626;
    --corial-error-bg: #fee2e2;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(121, 24, 18, 0.04);
    --shadow-md: 0 2px 8px rgba(121, 24, 18, 0.06);
    --shadow-lg: 0 8px 24px rgba(121, 24, 18, 0.08);
    --shadow-xl: 0 12px 32px rgba(121, 24, 18, 0.12);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* ================================================
   Base Styles
   ================================================ */

*, *::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: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    color: var(--corial-text-primary);
    background: var(--corial-eggshell);
}

/* ================================================
   Typography
   ================================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--corial-text-primary);
}

h1 { font-size: 2.5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.875rem; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--corial-berry);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--corial-berry-dark);
}

/* ================================================
   Layout Components
   ================================================ */

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.card {
    background: var(--corial-white);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(121, 24, 18, 0.08);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--corial-berry);
}

/* ================================================
   Buttons
   ================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--corial-berry);
    color: white;
}

/* Back button - volta à página anterior */
.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}
.back-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    opacity: 0.85;
}
.back-btn:active {
    opacity: 0.7;
}
.back-btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary:hover {
    background: var(--corial-berry-dark);
}

.btn-secondary {
    background: var(--corial-berry-light);
    color: var(--corial-berry);
}

.btn-secondary:hover {
    background: rgba(121, 24, 18, 0.12);
}

.btn-outline {
    background: transparent;
    color: var(--corial-berry);
    border: 1px solid var(--corial-berry);
}

.btn-outline:hover {
    background: var(--corial-berry);
    color: white;
}

/* ================================================
   Form Elements
   ================================================ */

.input, .select, .textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--corial-text-primary);
    background: var(--corial-white);
    border: 1px solid rgba(121, 24, 18, 0.15);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--corial-berry);
    box-shadow: 0 0 0 3px var(--corial-berry-light);
}

.input::placeholder {
    color: var(--corial-text-light);
}

.label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: 500;
    color: var(--corial-text-secondary);
}

/* ================================================
   Tables
   ================================================ */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(121, 24, 18, 0.08);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

th, td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(121, 24, 18, 0.06);
}

th {
    background: var(--corial-cream);
    font-weight: 600;
    color: var(--corial-text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

tr:hover td {
    background: var(--corial-berry-lighter);
}

/* ================================================
   Status Badges
   ================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-success {
    background: var(--corial-success-bg);
    color: var(--corial-success);
}

.badge-warning {
    background: var(--corial-warning-bg);
    color: var(--corial-warning);
}

.badge-info {
    background: var(--corial-info-bg);
    color: var(--corial-info);
}

.badge-error {
    background: var(--corial-error-bg);
    color: var(--corial-error);
}

.badge-neutral {
    background: #f3f4f6;
    color: #6b7280;
}

/* ================================================
   Dashboard Specific
   ================================================ */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    background: var(--corial-white);
    border-bottom: 1px solid rgba(121, 24, 18, 0.08);
}

.dashboard-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--corial-berry);
}

.dashboard-nav {
    display: flex;
    gap: var(--space-sm);
}

.nav-tab {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--corial-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-tab:hover {
    background: var(--corial-berry-light);
    color: var(--corial-berry);
}

.nav-tab.active {
    background: var(--corial-berry);
    color: white;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.kpi-card {
    background: var(--corial-white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid rgba(121, 24, 18, 0.08);
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--corial-text-muted);
    margin-bottom: var(--space-xs);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--corial-text-primary);
}

.kpi-change {
    font-size: 0.85rem;
    margin-top: var(--space-xs);
}

.kpi-change.positive {
    color: var(--corial-success);
}

.kpi-change.negative {
    color: var(--corial-error);
}

/* ================================================
   Password Protection Overlay
   ================================================ */

.password-overlay {
    position: fixed;
    inset: 0;
    background: var(--corial-eggshell);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.password-box {
    background: var(--corial-white);
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.password-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--corial-berry);
    margin-bottom: var(--space-lg);
}

.password-input-group {
    margin: var(--space-lg) 0;
}

/* ========================================
   LOGO - Day/Night Mode
======================================== */

.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 28px;
    width: auto;
}

/* Day mode (default) - Red logo */
.logo-img.logo-night {
    display: none;
}

.logo-img.logo-day {
    display: block;
}

/* Night mode - Beige logo */
.dark-header .logo-img.logo-day,
.header-dark .logo-img.logo-day {
    display: none;
}

.dark-header .logo-img.logo-night,
.header-dark .logo-img.logo-night {
    display: block;
}

/* ========================================
   USER MENU - DROPDOWN COMPLETO
======================================== */

/* Container principal */
.user-menu {
    position: relative;
}

/* Botão trigger */
.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: rgba(254, 249, 227, 0.15);
    color: #FEF9E3;
    font-family: inherit;
    font-size: 14px;
}

.user-menu-trigger:hover {
    background: rgba(254, 249, 227, 0.25);
}

/* Avatar */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #791812;
    color: #FEF9E3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    border: 2px solid #FEF9E3;
}

/* Nome e seta */
.user-name {
    font-weight: 500;
    font-size: 14px;
    color: #FEF9E3;
}

.chevron-icon {
    width: 16px;
    height: 16px;
    stroke: #FEF9E3;
    transition: transform 0.2s ease;
}

.user-menu.active .chevron-icon {
    transform: rotate(180deg);
}

/* DROPDOWN */
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(52, 33, 25, 0.2);
    border: 1px solid rgba(52, 33, 25, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

/* ESTADO ACTIVO - MOSTRAR DROPDOWN */
.user-menu.active .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Header do dropdown */
.dropdown-header {
    padding: 16px;
    background: #FEF9E3;
    border-bottom: 1px solid rgba(52, 33, 25, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dropdown-avatar,
.avatar-large {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #791812;
    color: #FEF9E3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.dropdown-user-details,
.user-info-details {
    flex: 1;
}

.dropdown-user-name,
.user-info-details h4 {
    font-weight: 600;
    color: #342119;
    font-size: 15px;
    margin: 0 0 2px 0;
}

.dropdown-user-email,
.user-info-details p {
    font-size: 13px;
    color: #666;
    margin: 0;
}

.dropdown-user-role,
.user-role-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    background: #791812;
    color: #FEF9E3;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Menu items */
.dropdown-menu,
.dropdown-menu-items {
    padding: 8px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #342119;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-item:hover {
    background: #FEF9E3;
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    stroke: #791812;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: rgba(52, 33, 25, 0.1);
    margin: 8px;
}

.dropdown-item.logout {
    color: #dc3545;
}

.dropdown-item.logout svg {
    stroke: #dc3545;
}

/* Admin-only items hidden by default */
.admin-only {
    display: none;
}

/* For light headers */
.header-light .user-menu-trigger {
    background: rgba(121, 24, 18, 0.05);
    color: var(--corial-text-primary);
}

.header-light .user-menu-trigger:hover {
    background: rgba(121, 24, 18, 0.1);
}

.header-light .user-avatar {
    border-color: #791812;
}

.header-light .user-name {
    color: var(--corial-text-primary);
}

.header-light .chevron-icon {
    stroke: var(--corial-text-primary);
}

/* ================================================
   Animations
   ================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

.animate-slide-up {
    animation: slideUp var(--transition-slow) ease-out;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* ================================================
   Responsive
   ================================================ */

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .container {
        padding: 0 var(--space-md);
    }
    
    .card {
        padding: var(--space-lg);
    }
    
    .dashboard-header {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

/* ================================================
   Utility Classes
   ================================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--corial-text-muted); }
.text-berry { color: var(--corial-berry); }
.text-success { color: var(--corial-success); }
.text-warning { color: var(--corial-warning); }
.text-error { color: var(--corial-error); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
