/* ========================================
   VARIABLES CSS
======================================== */
:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #1abc9c;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --bg-color: #f5f7fa;
    --text-color: #2c3e50;
    --border-color: #dfe6e9;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
    --header-height: 60px;
    --navbar-height: 65px;
    --sidebar-width: 260px;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* ========================================
   RESET & BASE
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: var(--navbar-height);
}

/* ========================================
   HEADER
======================================== */
.main-header {
    background: white;
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 100;
}

.header-content {
    padding: 0 20px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-color);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.site-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-title i {
    font-size: 1.8rem;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-button {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
}

.user-button:hover {
    background: var(--light-color);
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-color);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
}

.user-dropdown a:hover {
    background: var(--light-color);
}

.user-dropdown a:first-child {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.user-dropdown a:last-child {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 5px 0;
}

/* ========================================
   MAIN CONTENT
======================================== */
.main-content {
    min-height: calc(100vh - var(--navbar-height));
    padding: 20px;
}

.main-content.with-navbar {
    padding-top: calc(var(--header-height) + 20px);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   BOTTOM NAVBAR
======================================== */
.bottom-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: var(--navbar-height);
    z-index: 100;
    padding: 5px 10px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #95a5a6;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 10px;
    transition: var(--transition);
    flex: 1;
    max-width: 100px;
}

.nav-item i {
    font-size: 1.5rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

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

.nav-item.active {
    color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}

/* ========================================
   FLASH MESSAGES
======================================== */
.flash-message {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    right: 20px;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
    max-width: calc(100vw - 40px);
}

.flash-success {
    background: var(--secondary-color);
    color: white;
}

.flash-error {
    background: var(--danger-color);
    color: white;
}

.flash-warning {
    background: var(--warning-color);
    color: white;
}

.flash-info {
    background: var(--info-color);
    color: white;
}

.flash-message button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: var(--transition);
}

.flash-message button:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ========================================
   CARDS
======================================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
    transition: var(--transition);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-color);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    margin-bottom: 15px;
}

/* ========================================
   BUTTONS
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    justify-content: center;
}

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

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #27ae60;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-light {
    background: var(--light-color);
    color: var(--text-color);
}

.btn-light:hover {
    background: #d5dbdb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ========================================
   FORMS
======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

/* ========================================
   SIDEBAR
======================================== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 149;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: white;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

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

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.sidebar-user .user-avatar {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 1rem;
}

.sidebar-user-role {
    font-size: 0.8rem;
    opacity: 0.85;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.sidebar-section-label {
    padding: 16px 20px 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #95a5a6;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.sidebar-item.active {
    background: rgba(52, 152, 219, 0.08);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar-item i {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-logout {
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    color: var(--danger-color);
}

.sidebar-logout:hover {
    background: rgba(231, 76, 60, 0.08);
    color: var(--danger-color);
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 0 10px;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .site-title i {
        font-size: 1.4rem;
    }

    .user-name {
        display: none;
    }

    .card {
        padding: 15px;
    }

    .card-title {
        font-size: 1.2rem;
    }
}

/* ========================================
   SMALL PHONES
======================================== */
@media (max-width: 480px) {
    /* Flash messages — full width on small screens */
    .flash-message {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    /* User dropdown — prevent overflow */
    .user-dropdown {
        right: -10px;
        min-width: 180px;
        max-width: calc(100vw - 40px);
    }

    /* Touch targets — minimum 44px per Apple/Google guidelines */
    .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .nav-item {
        min-height: 44px;
    }

    .user-button {
        min-height: 44px;
    }

    /* Form inputs — 16px prevents iOS auto-zoom */
    .form-control {
        font-size: 16px !important;
    }

    /* Sidebar items — comfortable tap targets */
    .sidebar-item {
        min-height: 48px;
    }
}

@media (min-width: 769px) {
    .bottom-navbar {
        display: none;
    }

    .main-content {
        padding-bottom: 20px;
    }

    /* Desktop : sidebar persistant */
    .sidebar {
        transform: translateX(0);
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        box-shadow: 1px 0 0 var(--border-color);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar-overlay {
        display: none;
    }

    .main-header {
        left: var(--sidebar-width);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .main-header.sidebar-collapsed {
        left: 0;
    }

    .main-content.with-navbar {
        margin-left: var(--sidebar-width);
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .sidebar-header {
        display: none;
    }

    body {
        padding-bottom: 0;
    }
}
