/* =========================================================================
   Base Variables & Theming
   ========================================================================= */
:root {
    /* Color Palette - Premium Dark Theme */
    --bg-main: #0f172a;
    /* Slate 900 */
    --bg-surface: #1e293b;
    /* Slate 800 */
    --bg-surface-hover: #334155;
    /* Slate 700 */

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */
    --text-muted: #64748b;
    /* Slate 500 */

    --border-color: #334155;
    /* Slate 700 */
    --border-light: rgba(255, 255, 255, 0.05);

    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --primary-light: rgba(99, 102, 241, 0.15);

    --success: #10b981;
    /* Emerald 500 */
    --success-light: rgba(16, 185, 129, 0.15);

    --warning: #f59e0b;
    /* Amber 500 */
    --warning-light: rgba(245, 158, 11, 0.15);

    --danger: #ef4444;
    /* Red 500 */
    --danger-light: rgba(239, 68, 68, 0.15);

    --purple: #8b5cf6;
    /* Violet 500 */
    --purple-light: rgba(139, 92, 246, 0.15);

    /* Layout & Sizing */
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
    --topbar-height: 70px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows & Transitions */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.3);

    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
}

/* =========================================================================
   Reset & Base Styles
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    display: flex;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input {
    border: none;
    outline: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

/* Utilities */
.text-primary {
    color: var(--primary);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-success {
    color: var(--success);
}

.text-muted {
    color: var(--text-muted);
}

/* =========================================================================
   Component: Sidebar
   ========================================================================= */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal);
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.logo i {
    font-size: 24px;
}

.toggle-btn {
    color: var(--text-secondary);
    font-size: 18px;
    padding: 8px;
    border-radius: 8px;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.toggle-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 20px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-link:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.nav-item.active .nav-link {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    width: 24px;
    font-size: 18px;
    margin-right: 16px;
    text-align: center;
    flex-shrink: 0;
}

.nav-text {
    flex: 1;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    display: none;
}

.sidebar.collapsed .logo span {
    opacity: 0;
    display: none;
}

.badge {
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.mobile-toggle-btn {
    display: none !important;
}

.badge-danger {
    background-color: var(--danger);
    color: white;
}

.sidebar-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 16px 24px;
}

.user-profile {
    margin-top: auto;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin-right: 12px;
}

/* =========================================================================
   Layout: Main Content
   ========================================================================= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-width-collapsed);
}

/* =========================================================================
   Component: Topbar
   ========================================================================= */
.topbar {
    height: var(--topbar-height);
    background-color: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    width: 350px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-bar i {
    color: var(--text-muted);
    margin-right: 12px;
}

.search-bar input {
    width: 100%;
    font-size: 14px;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.action-btn {
    position: relative;
    padding: 10px;
    border-radius: 10px;
    color: var(--text-secondary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    padding: 10px 20px;
    gap: 8px;
    font-weight: 500;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
    box-shadow: var(--shadow-glow);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
}

/* Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.1);
}

.notification-body {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notification-item:hover {
    background-color: var(--bg-surface-hover);
}

.notification-item.unread {
    background-color: rgba(99, 102, 241, 0.05);
    /* very light primary */
    border-left: 3px solid var(--primary);
}

.notif-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notif-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-message {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notif-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* =========================================================================
   View: Dashboard Container
   ========================================================================= */
.dashboard-container {
    padding: 40px;
    min-width: 0;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.welcome-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

.date-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
}

/* Component: Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.metric-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.card-blue::before {
    background-color: var(--primary);
}

.card-purple::before {
    background-color: var(--purple);
}

.card-orange::before {
    background-color: var(--warning);
}

.card-red::before {
    background-color: var(--danger);
}

.card-green::before {
    background-color: var(--success);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.card-blue .metric-icon {
    background-color: var(--primary-light);
    color: var(--primary);
}

.card-purple .metric-icon {
    background-color: var(--purple-light);
    color: var(--purple);
}

.card-green .metric-icon {
    background-color: rgba(34, 197, 94, 0.15);
    /* success light */
    color: var(--success);
}

.card-orange .metric-icon {
    background-color: var(--warning-light);
    color: var(--warning);
}

.card-red .metric-icon {
    background-color: var(--danger-light);
    color: var(--danger);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1;
}

.metric-trend {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.metric-trend.positive {
    color: var(--success);
}

.metric-trend.negative {
    color: var(--danger);
}

.metric-trend.neutral {
    color: var(--text-secondary);
}

/* Layout: Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.btn-text {
    color: var(--primary);
    font-weight: 500;
    font-size: 13px;
}

.btn-text:hover {
    text-decoration: underline;
}

/* Component: Data Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 16px 24px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px 24px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Table specific styling */
.badge-outline {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    background-color: var(--bg-main);
}

td strong {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sub-text {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.date-text {
    font-weight: 500;
}

/* Specific Rows Highlighting */
.data-table tr.row-danger td:first-child {
    box-shadow: inset 3px 0 0 var(--danger);
}

.data-table tr.row-warning td:first-child {
    box-shadow: inset 3px 0 0 var(--warning);
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}

.status-critical {
    background-color: var(--danger-light);
    color: var(--danger);
}

.status-high {
    background-color: var(--warning-light);
    color: var(--warning);
}

.status-medium {
    background-color: var(--purple-light);
    color: var(--purple);
}

.status-low {
    background-color: var(--success-light);
    color: var(--success);
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--text-muted);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

.icon-btn .fa-check:hover {
    color: var(--success);
}

/* Charts container */
.chart-container {
    padding: 24px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .dashboard-container {
        padding: 20px;
    }

    .search-bar {
        width: 100%;
        max-width: 200px;
    }

    .mobile-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        color: var(--text-primary);
        background: none;
        border: none;
        padding: 5px;
    }
}

/* =========================================================================
   Component: Modal (Novo Prazo)
   ========================================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    color: var(--text-muted);
    font-size: 20px;
    transition: color var(--transition-fast);
}

.close-btn:hover {
    color: var(--text-primary);
}

#form-deadline {
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Reusing auth-input styles from auth.js */
.auth-input {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
    outline: none;
}

select.auth-input option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.modal-footer {
    margin-top: 32px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    align-items: center;
}