/* Reset e Variáveis */
:root {
    --primary-color: #1e3a8a;
    --secondary-color: #3b82f6;
    --accent-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --text-color: #1e293b;
    --sidebar-bg: #ffffff;
    --sidebar-width: 300px;
    --header-height: 80px;
    --border-radius: 12px;
    --box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-primary: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    --gradient-secondary: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

[data-theme="dark"] {
    --primary-color: #0f172a;
    --secondary-color: #3b82f6;
    --accent-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --background-color: #1e293b;
    --text-color: #f1f5f9;
    --sidebar-bg: #0f172a;
    --gradient-primary: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-secondary: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    transition: var(--transition);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.main-header {
    background: var(--gradient-primary);
    color: white;
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.main-header .container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    height: 45px;
    width: auto;
    filter: brightness(1.1);
    transition: var(--transition);
}

.logo:hover {
    filter: brightness(1.2) scale(1.05);
    transform: scale(1.05);
}

.logo:error {
    display: none;
}

/* Fallback for logo loading issues */
.logo {
    object-fit: contain;
    max-height: 45px;
    max-width: 150px;
}

.header-text h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-text p {
    font-size: 0.95rem;
    opacity: 0.85;
    font-weight: 400;
}

.header-nav {
    display: flex;
    gap: 10px;
}

.theme-toggle,
.menu-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 1.1rem;
    padding: 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.theme-toggle:hover,
.menu-toggle:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--sidebar-bg);
    box-shadow: var(--box-shadow);
    transform: translateX(-100%);
    transition: var(--transition);
    z-index: 999;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0,0,0,0.1);
}

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

.sidebar-header {
    padding: 24px;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.sidebar-menu {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.menu-item {
    margin: 4px 16px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    border-radius: var(--border-radius);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.menu-link:hover {
    background: var(--gradient-secondary);
    color: var(--secondary-color);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.menu-link.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    transform: translateX(4px);
}

.menu-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-color);
}

.menu-link i,
.menu-icon,
.menu-link .icon {
    width: 24px;
    text-align: center;
    font-size: 1.2rem;
    transition: var(--transition);
    display: inline-block;
}

.menu-link:hover i,
.menu-link:hover .menu-icon,
.menu-link:hover .icon {
    transform: scale(1.1);
}

.menu-link.active i,
.menu-link.active .menu-icon,
.menu-link.active .icon {
    transform: scale(1.1);
}

.menu-link.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.menu-link.loading::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
    background: var(--gradient-secondary);
}

.admin-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
    background: rgba(255,255,255,0.8);
    border: 1px solid rgba(0,0,0,0.1);
}

.admin-link:hover {
    background: white;
    color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-top: var(--header-height);
    padding: 8px;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

.iframe-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.content-iframe {
    width: 100%;
    height: 100%;
    border: none;
    transition: var(--transition);
}

.hidden {
    display: none !important;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--background-color);
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 24px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 500;
    opacity: 0.8;
}

/* Welcome Screen */
.welcome-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-color);
    max-width: 600px;
    padding: 0 32px;
}

.welcome-icon {
    font-size: 5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.welcome-content h2 {
    margin-bottom: 20px;
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.welcome-content p {
    font-size: 1.2rem;
    opacity: 0.7;
    margin-bottom: 16px;
    line-height: 1.6;
}

.welcome-info {
    margin-top: 40px;
    padding: 32px;
    background: var(--gradient-secondary);
    border-radius: var(--border-radius);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: var(--box-shadow);
}

.welcome-info p {
    margin-bottom: 8px;
    font-size: 1.1rem;
    font-weight: 500;
}

.welcome-info strong {
    color: var(--secondary-color);
    font-weight: 700;
}

/* Error Screen */
.error-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-color);
    max-width: 500px;
    padding: 0 32px;
}

.error-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 24px;
    animation: shake 0.5s ease-in-out infinite alternate;
}

@keyframes shake {
    0% { transform: translateX(0); }
    100% { transform: translateX(-4px); }
}

.error-content h3 {
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--accent-color);
    font-weight: 700;
}

.error-content p {
    margin-bottom: 32px;
    font-size: 1.2rem;
    opacity: 0.7;
    line-height: 1.6;
}

.retry-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: var(--box-shadow);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

/* Footer */
.main-footer {
    display: none;
}

/* Responsive Design */
@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }
    
    .sidebar {
        transform: translateX(0);
        position: fixed;
        top: var(--header-height);
        left: 0;
        height: calc(100vh - var(--header-height));
        z-index: 999;
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
    
    .overlay {
        display: none;
    }
}

@media (max-width: 767px) {
    .header-text h1 {
        font-size: 1.2rem;
    }
    
    .header-text p {
        display: none;
    }
    
    .sidebar {
        width: 100%;
        max-width: 320px;
    }
    
    .main-content {
        padding: 10px;
    }
    
    .welcome-content h2 {
        font-size: 2rem;
    }
    
    .welcome-icon {
        font-size: 3.5rem;
    }
    
    .welcome-info {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .main-header .container {
        padding: 0 10px;
    }
    
    .header-brand {
        gap: 10px;
    }
    
    .logo {
        height: 35px;
    }
    
    .header-text h1 {
        font-size: 1.1rem;
    }
    
    .sidebar-header {
        padding: 15px;
    }
    
    .welcome-content h2 {
        font-size: 1.3rem;
    }
    
    .welcome-content p {
        font-size: 1rem;
    }
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

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

.welcome-screen,
.error-screen {
    animation: fadeIn 0.5s ease;
}

/* Ícones customizados */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    vertical-align: middle;
    font-size: 16px;
}

.icon.chart-bar::before { content: '📊'; }
.icon.chart-line::before { content: '📈'; }
.icon.chart-pie::before { content: '🥧'; }
.icon.dashboard::before { content: '🎛️'; }
.icon.bus::before { content: '🚌'; }
.icon.car::before { content: '🚗'; }
.icon.traffic-light::before { content: '🚦'; }
.icon.route::before { content: '🛣️'; }
.icon.map::before { content: '🗺️'; }
.icon.users::before { content: '👥'; }
.icon.report::before { content: '📋'; }
.icon.database::before { content: '🗄️'; }
.icon.settings::before { content: '⚙️'; }

.icon::before {
    font-size: 16px;
    display: inline-block;
    width: 20px;
    text-align: center;
}

/* Ícones na sidebar */
.menu-link .icon {
    width: 24px;
    font-size: 1.2rem;
}

.menu-link .icon::before {
    font-size: 1.2rem;
    width: 24px;
}

/* Print Styles */
@media print {
    .main-header,
    .sidebar,
    .overlay {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .iframe-container {
        height: 100vh !important;
        box-shadow: none !important;
    }
}