@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700&family=Roboto:wght@400;500&display=swap');

:root {
    /* Brand Colors */
    --primary-color: #F0512A;
    /* Primary Orange */
    --primary-hover: #d6401d;
    --secondary-color: #EE9F20;
    /* Secondary Yellow */
    --success-color: #74BC70;
    /* Success Green */
    --surface-color: #ffffff;
    --background-color: #f8fafc;

    /* Typography Colors */
    --text-primary: #44546A;
    /* Dark Blue/Grey */
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Dark sidebar colors */
    --sidebar-bg: #44546A;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: rgba(255, 255, 255, 0.7);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg: rgba(240, 81, 42, 0.2);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    margin: 0;
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
.logo {
    font-family: 'Montserrat', sans-serif;
    margin-top: 0;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.center-flex {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Card Component */
.card {
    background-color: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--border-color);
}

/* Navbar */
.navbar {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* Navbar & User Menu */
.navbar {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: fixed;
    /* Fixed header */
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 64px;
    box-sizing: border-box;
}

body {
    padding-top: 64px;
    /* Space for fixed navbar */
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 64px;
    /* Below navbar */
    left: 0;
    bottom: 0;
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: none;
    transform: translateX(-100%);
    /* Hidden by default */
    transition: transform 0.3s ease-in-out;
    z-index: 40;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    /* Shadow when overlaying */
}

/* Pinned State */
body.pinned-sidebar .sidebar {
    transform: translateX(0);
    box-shadow: none;
}

body.pinned-sidebar .container {
    margin-left: 260px;
    /* Push content */
}

/* Hide hamburger when pinned (optional - cleaner UI) */
body.pinned-sidebar .hamburger {
    opacity: 0.5;
    pointer-events: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    padding: 0.75rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--primary-color);
}

.sidebar-heading {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 0.5rem;
    display: flex;
    align-items: center;
    border-radius: var(--radius);
}

.hamburger:hover {
    background-color: var(--background-color);
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    /* In case it's a link */
}

/* Dropdown Container */
.user-menu-container {
    position: relative;
    cursor: pointer;
}

.user-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background-color 0.2s;
}

.user-toggle:hover {
    background-color: var(--background-color);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 200px;
    display: none;
    /* Hidden by default */
    z-index: 1000;
    padding: 0.5rem 0;
}

.user-menu-container:hover .user-dropdown {
    display: block;
}

/* Invisible bridge to prevent menu from closing when moving mouse over the gap */
.user-dropdown::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    left: 0;
    width: 100%;
    height: 0.5rem;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--background-color);
    color: var(--primary-color);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    /* Fix padding expanding width */
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(240, 81, 42, 0.1);
}

.form-control[readonly] {
    background-color: var(--background-color);
    cursor: default;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

/* Flash Messages */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablet and below (< 1024px) */
@media (max-width: 1024px) {
    body.pinned-sidebar .container {
        margin-left: 0;
    }

    body.pinned-sidebar .sidebar {
        transform: translateX(-100%);
    }

    body.pinned-sidebar .sidebar.open {
        transform: translateX(0);
    }

    body.pinned-sidebar .hamburger {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Mobile devices (< 768px) */
@media (max-width: 768px) {
    /* Navbar adjustments */
    .navbar {
        padding: 0.75rem 1rem;
        height: 56px;
    }

    body {
        padding-top: 56px;
    }

    .sidebar {
        top: 56px;
        width: 280px;
    }

    .logo {
        font-size: 1rem;
    }

    /* Hide user name on small screens, show only avatar/icon */
    .user-toggle .user-name {
        display: none;
    }

    /* Container adjustments */
    .container {
        padding: 1rem;
    }

    /* Card adjustments */
    .card {
        padding: 1rem;
        border-radius: 0.5rem;
    }

    /* Form adjustments */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        padding: 0.625rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Button adjustments */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    /* Typography adjustments */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    /* Page header adjustments */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header .btn {
        width: 100%;
    }

    /* Table responsive wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    /* Generic table mobile styles */
    table {
        font-size: 0.875rem;
    }

    table th,
    table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }

    /* Stack flex layouts vertically on mobile */
    .flex-row-mobile-stack {
        flex-direction: column;
        align-items: stretch;
    }

    /* Modal adjustments */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        width: calc(100% - 2rem) !important;
        max-width: none !important;
    }

    /* Dropdown menus */
    .user-dropdown {
        right: -0.5rem;
        min-width: 180px;
    }

    /* Sidebar overlay for mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 35;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Small mobile devices (< 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .card {
        padding: 0.875rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.5rem 0.875rem;
    }

    /* Full width buttons on very small screens */
    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }

    table th,
    table td {
        padding: 0.375rem 0.25rem;
        font-size: 0.8rem;
    }
}

/* Utility classes for responsive behavior */
.hide-mobile {
    display: block;
}

.show-mobile {
    display: none;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .show-mobile {
        display: block !important;
    }

    .show-mobile-inline {
        display: inline !important;
    }

    .show-mobile-flex {
        display: flex !important;
    }
}

/* Responsive grid utilities */
.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

@media (max-width: 768px) {
    .grid-responsive {
        grid-template-columns: 1fr;
    }
}

/* Touch-friendly tap targets */
@media (max-width: 768px) {
    .sidebar-link {
        padding: 1rem 1.5rem;
        min-height: 44px;
    }

    .dropdown-item {
        padding: 1rem;
        min-height: 44px;
    }

    .hamburger {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }
}