/* =====================================================
   JUBIROSCA - Design System
   Glassmorphism + Dark/Light Theme
   ===================================================== */

/* ===== CSS Variables - Theme System ===== */
:root {
    /* Primary Colors */
    --accent: #2563eb;
    --accent-light: #3b82f6;
    --accent-dark: #1d4ed8;
    --accent-rgb: 37, 99, 235;
    
    /* Success/Warning/Danger */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Light Theme (Default) */
[data-theme="light"], :root {
    --bg-body: #f0f4f8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: rgba(0, 0, 0, 0.08);
    
    --card-bg: rgba(255, 255, 255, 0.85);
    --sidebar-bg: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.5) 100%);
    
    --border-color: rgba(0, 0, 0, 0.08);
    --input-bg: rgba(255, 255, 255, 0.8);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-primary: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(71, 85, 105, 0.5);
    --glass-shadow: rgba(0, 0, 0, 0.3);
    
    --card-bg: rgba(30, 41, 59, 0.85);
    --sidebar-bg: linear-gradient(135deg, rgba(30,41,59,0.9) 0%, rgba(15,23,42,0.8) 100%);
    
    --border-color: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(30, 41, 59, 0.8);
}

/* ===== Base Styles ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body) !important;
    color: var(--text-primary) !important;
    min-height: 100vh;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

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

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

/* ===== Glassmorphism Components ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px var(--glass-shadow);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px var(--glass-shadow);
}

.glass-sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--glass-border);
}

.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

.glass-modal .modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.glass-modal .modal-header {
    border-bottom: 1px solid var(--border-color);
}

.glass-modal .modal-footer {
    border-top: 1px solid var(--border-color);
}

/* ===== Dropdown Menu ===== */
.dropdown-menu.glass {
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.dropdown-menu .dropdown-item {
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    margin: 0.125rem 0.25rem;
    transition: all var(--transition-fast);
}

.dropdown-menu .dropdown-item:hover {
    background: var(--glass-bg);
    color: var(--accent);
}

.dropdown-menu .dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.dropdown-menu .dropdown-item-text {
    color: var(--text-primary);
}

.dropdown-menu .dropdown-divider {
    border-color: var(--border-color);
}

/* ===== Navigation ===== */
.glass-nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glass-nav-link:hover {
    background: var(--glass-bg);
    color: var(--accent);
    transform: translateX(4px);
}

.glass-nav-link.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
}

.glass-nav-link.active:hover {
    color: white;
    transform: translateX(0);
}

/* ===== Buttons ===== */
.btn {
    font-weight: 500;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.5);
}

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

.btn-outline-primary:hover {
    background: var(--accent);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

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

/* ===== Forms ===== */
.form-control, .form-select {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.15);
    outline: none;
}

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

.form-label {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* ===== Cards ===== */
.card-gradient-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    color: white;
    border: none;
}

.card-gradient-primary .text-white-50 {
    color: rgba(255, 255, 255, 0.7) !important;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%) !important;
    color: white !important;
}

/* ===== Progress Bars ===== */
.progress {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ===== Tables ===== */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--glass-bg);
}

.table td, .table th {
    border-color: var(--border-color);
    vertical-align: middle;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: var(--radius-full);
}

.badge.bg-primary-subtle {
    background: rgba(var(--accent-rgb), 0.15) !important;
    color: var(--accent) !important;
}

.badge.bg-success-subtle {
    background: rgba(16, 185, 129, 0.15) !important;
    color: var(--success) !important;
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--radius-md);
    border: none;
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.theme-toggle:hover {
    background: var(--accent);
    color: white;
    transform: rotate(15deg);
}

.theme-toggle .bi-sun-fill {
    display: none;
}

.theme-toggle .bi-moon-fill {
    display: block;
}

[data-theme="dark"] .theme-toggle .bi-sun-fill {
    display: block;
}

[data-theme="dark"] .theme-toggle .bi-moon-fill {
    display: none;
}

/* ===== Layout ===== */
.dashboard-container {
    padding: 1.5rem;
    min-height: calc(100vh - 80px);
}

@media (min-width: 992px) {
    .dashboard-container {
        padding: 2rem;
    }
}

/* ===== Auth Pages ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
}

.auth-sidebar {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    position: relative;
    overflow: hidden;
}

.auth-sidebar::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse 15s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.3; }
}

.auth-content-overlay {
    position: relative;
    z-index: 2;
}

/* ===== Navbar ===== */
.navbar-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-weight: 700;
    color: var(--text-primary) !important;
    font-size: 1.25rem;
}

/* ===== Footer ===== */
.footer-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

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

.slide-up {
    animation: slideUp 0.5s ease-out;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .glass-sidebar {
        border-right: none;
        border-radius: 0;
    }
    
    .dashboard-container {
        padding: 1rem;
    }
}

@media (max-width: 767.98px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .glass-card {
        border-radius: var(--radius-md);
    }
}

/* ===== Utilities ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-blur {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.border-glass {
    border: 1px solid var(--glass-border);
}

/* Fix for Bootstrap text colors in dark mode */
[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-light {
    background: var(--bg-secondary) !important;
}

[data-theme="dark"] .bg-white {
    background: var(--bg-primary) !important;
}

[data-theme="dark"] .border-light {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .table-light {
    background: var(--bg-secondary) !important;
    color: var(--text-primary);
}

/* Offcanvas Dark Mode */
[data-theme="dark"] .offcanvas {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Modal Dark Mode */
[data-theme="dark"] .modal-content {
    background: var(--card-bg);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

/* ===== Mobile Touch/Click Fixes ===== */
/* Garantir que elementos interativos funcionem no PWA mobile */

/* Botões e links devem ser clicáveis */
.btn, 
a, 
button,
.dropdown-toggle,
.nav-link,
.glass-nav-link,
[data-bs-toggle],
[data-bs-dismiss],
input,
select,
textarea,
.form-control,
.form-select {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

/* Navbar deve ter z-index alto */
.navbar,
.navbar-glass {
    position: relative;
    z-index: 1030;
}

/* Dropdowns devem aparecer acima de tudo */
.dropdown-menu {
    z-index: 1050;
}

/* Modais devem estar no topo */
.modal {
    z-index: 1055;
}

.modal-backdrop {
    z-index: 1050;
}

.modal-dialog {
    z-index: 1060;
}

/* Offcanvas para mobile */
.offcanvas {
    z-index: 1045;
}

.offcanvas-backdrop {
    z-index: 1040;
}

/* Garantir que glass-card seja clicável */
.glass-card {
    position: relative;
    z-index: 1;
}

/* Fix para botões dentro de cards */
.glass-card .btn,
.glass-card a,
.glass-card button {
    z-index: 10;
}

/* Fix para animações não bloquearem cliques */
.fade-in,
.slide-up {
    pointer-events: auto;
}

/* Garantir que o body não bloqueie cliques */
body {
    touch-action: pan-x pan-y;
}

/* Fix específico para iOS Safari PWA */
@supports (-webkit-touch-callout: none) {
    body {
        /* Prevenir zoom indesejado */
        -webkit-text-size-adjust: 100%;
    }
    
    /* Garantir que os botões respondam ao toque */
    .btn,
    button,
    a {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}
