/* ==========================================================================
   TUTRAMITADOR - MODERN DESIGN SYSTEM (APP.CSS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Brand Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-light: #eff6ff;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* Light Theme (Default) */
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-sidebar: #0f172a;
    --text-sidebar: #94a3b8;
    --text-sidebar-hover: #f1f5f9;
    --text-sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(37, 99, 235, 0.2);
    --border-sidebar: rgba(255, 255, 255, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    
    --topbar-bg: rgba(255, 255, 255, 0.85);
    --topbar-border: #e2e8f0;
    
    --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
    --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --card-radius: 14px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-bs-theme="dark"], body.dark-mode {
    --bg-app: #0b0f19;
    --bg-card: #111827;
    --bg-card-hover: #1f2937;
    --bg-sidebar: #070a13;
    --text-sidebar: #9ca3af;
    --text-sidebar-hover: #f3f4f6;
    --text-sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(37, 99, 235, 0.35);
    --border-sidebar: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #1f2937;
    --border-light: #283244;
    
    --topbar-bg: rgba(17, 24, 39, 0.85);
    --topbar-border: #1f2937;
    
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --card-shadow-hover: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

/* Base Elements */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    color: var(--primary-hover);
}

/* ==========================================================================
   APP LAYOUT ARCHITECTURE
   ========================================================================== */

.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* SIDEBAR */
.app-sidebar {
    width: 270px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid var(--border-sidebar);
}

.brand-icon-wrapper {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.72rem;
    color: var(--text-sidebar);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-menu-wrapper {
    padding: 1.25rem 0.85rem;
    overflow-y: auto;
    flex-grow: 1;
}

.sidebar-menu-category {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.35);
    padding: 0.6rem 0.85rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--text-sidebar);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    transition: var(--transition);
    position: relative;
}

.sidebar-nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    color: inherit;
    transition: var(--transition);
}

.sidebar-nav-link:hover {
    color: var(--text-sidebar-hover);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-link:hover i {
    color: #60a5fa;
}

.sidebar-nav-link.active {
    color: var(--text-sidebar-active);
    background: var(--sidebar-active-bg);
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

.sidebar-nav-link.active i {
    color: #60a5fa;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-sidebar);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-user-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-sm {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* MAIN CONTENT AREA */
.app-main {
    margin-left: 270px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 270px);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* TOPBAR */
.app-topbar {
    height: 70px;
    background-color: var(--topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--topbar-border);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    transition: var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    padding: 0.4rem;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    transition: var(--transition);
}

.btn-sidebar-toggle:hover {
    color: var(--text-primary);
    background-color: var(--border-light);
}

.topbar-page-info h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.topbar-page-info .breadcrumb {
    margin: 0;
    font-size: 0.75rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Theme Toggle Button */
.btn-theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background-color: var(--border-light);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: rotate(15deg);
}

/* User Dropdown */
.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.65rem;
    border-radius: 30px;
    background-color: var(--border-light);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user-btn:hover {
    background-color: var(--border-color);
}

.dropdown-menu {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    box-shadow: var(--card-shadow-hover);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.88rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(37, 99, 235, 0.15);
    color: #93c5fd;
}

/* APP BODY CONTENT */
.app-content {
    padding: 2rem 1.75rem;
    flex-grow: 1;
}

/* ==========================================================================
   UI COMPONENTS & CARDS
   ========================================================================== */

/* Modern Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

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

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: transparent;
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* Stat Metric Cards */
.stat-card-modern {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

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

.stat-card-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--primary));
    border-top-left-radius: var(--card-radius);
    border-bottom-left-radius: var(--card-radius);
}

.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    background-color: var(--stat-bg, rgba(37, 99, 235, 0.1));
    color: var(--stat-color, var(--primary));
}

.stat-number {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1;
    margin-top: 0.5rem;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

/* Color Presets for Stat Cards */
.stat-card-blue { --stat-color: #2563eb; --stat-bg: rgba(37, 99, 235, 0.1); }
.stat-card-amber { --stat-color: #f59e0b; --stat-bg: rgba(245, 158, 11, 0.1); }
.stat-card-emerald { --stat-color: #10b981; --stat-bg: rgba(16, 185, 129, 0.1); }
.stat-card-rose { --stat-color: #ef4444; --stat-bg: rgba(239, 68, 68, 0.1); }
.stat-card-purple { --stat-color: #8b5cf6; --stat-bg: rgba(139, 92, 246, 0.1); }

/* Soft Badges */
.badge {
    font-weight: 600;
    padding: 0.45em 0.85em;
    border-radius: 8px;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.badge-soft-primary {
    background-color: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge-soft-success {
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-soft-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-soft-danger {
    background-color: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.badge-soft-secondary {
    background-color: rgba(148, 163, 184, 0.15);
    color: #64748b;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Dark theme badge adjustments */
[data-bs-theme="dark"] .badge-soft-primary { color: #60a5fa; }
[data-bs-theme="dark"] .badge-soft-success { color: #34d399; }
[data-bs-theme="dark"] .badge-soft-warning { color: #fbbf24; }
[data-bs-theme="dark"] .badge-soft-danger  { color: #f87171; }
[data-bs-theme="dark"] .badge-soft-secondary { color: #cbd5e1; }

/* Modern Table */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern thead th {
    background-color: var(--border-light);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.95rem 1rem;
    border-top: none;
    border-bottom: 1px solid var(--border-color);
}

.table-modern thead th:first-child { border-top-left-radius: 10px; }
.table-modern thead th:last-child { border-top-right-radius: 10px; }

.table-modern tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.88rem;
    background-color: var(--bg-card);
    transition: background-color 0.15s ease;
}

.table-modern tbody tr:hover td {
    background-color: rgba(37, 99, 235, 0.03);
}

[data-bs-theme="dark"] .table-modern tbody tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Modern Form Controls */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.form-control, .form-select {
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.95rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
    color: var(--text-primary);
}

.input-group-text {
    background-color: var(--border-light);
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 10px;
}

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: 10px;
    padding: 0.6rem 1.25rem;
    font-size: 0.88rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
    color: #ffffff;
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #ffffff;
}

/* Modern Alerts */
.modern-alert {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 1rem 1.25rem;
}

/* Timeline component */
.timeline-modern {
    position: relative;
    padding-left: 2rem;
    margin: 1.5rem 0;
}

.timeline-modern::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-node {
    position: absolute;
    left: -2rem;
    top: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--bg-app);
}

.timeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
}

/* Backdrop for Mobile Sidebar */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    backdrop-filter: blur(4px);
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */

@media (max-width: 991.98px) {
    .btn-sidebar-toggle {
        display: inline-flex;
    }
    
    .app-sidebar {
        transform: translateX(-100%);
    }
    
    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }
    
    body.sidebar-open .sidebar-backdrop {
        display: block;
    }
    
    .app-main {
        margin-left: 0;
        width: 100%;
    }
    
    .app-content {
        padding: 1.25rem 1rem;
    }
    
    .app-topbar {
        padding: 0 1rem;
    }
}
