/* ==========================================
   ENHANCED PURCHASE MANAGER THEME
   Modern, Productive, Professional
   ========================================== */

* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #10b981;
    --secondary-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== NAVBAR ==================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 12px 28px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 22px;
    color: var(--primary);
    text-decoration: none;
    margin-right: 20px;
}

.navbar-brand i {
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.navbar-menu a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.navbar-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.navbar-menu a:hover::after {
    width: 100%;
}

.navbar-menu a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.navbar-menu a.active {
    color: var(--primary);
    background: var(--primary-light);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 14px;
}

.user-name {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
}

.logout-btn {
    border: 2px solid var(--danger);
    background: var(--danger-light);
    color: var(--danger);
    border-radius: var(--radius-lg);
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 1400px;
    margin: 32px auto 40px;
    padding: 0 20px;
}

.page-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.page-header-content h1 {
    font-size: 36px;
    margin: 0 0 8px;
    color: var(--text-primary);
    font-weight: 800;
}

.page-header-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.page-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==================== TOOLBAR ==================== */
.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 13px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.filter-btn,
.export-btn,
.btn-secondary {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-btn:hover,
.export-btn:hover,
.btn-secondary:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    border: none;
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    border: none;
    border-radius: var(--radius-lg);
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%);
    color: white;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    border: none;
    border-radius: var(--radius-lg);
    padding: 8px 14px;
    background: var(--danger-light);
    color: var(--danger);
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
}

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

/* ==================== METRIC CARDS ==================== */
.metric-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.metric-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.metric-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-card .value {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
}

.metric-card .trend {
    font-size: 12px;
    color: var(--secondary);
    margin-top: 8px;
    font-weight: 600;
}

.metric-card .trend.down {
    color: var(--danger);
}

/* ==================== DASHBOARD GRID ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 26px;
}

.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(600px at var(--mouse-x, 0) var(--mouse-y, 0), rgba(37, 99, 235, 0.05), transparent 80%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card:hover::before {
    opacity: 1;
}

.card-icon {
    font-size: 32px;
    background: linear-gradient(135deg, var(--primary-light), #e0f2fe);
    width: 60px;
    height: 60px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    margin-bottom: 16px;
}

.card-title {
    margin: 0 0 10px;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 700;
}

.card-description {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.card-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
    transition: all 0.3s ease;
}

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

/* ==================== TABLE ==================== */
.table-wrapper {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    overflow: auto;
    margin-bottom: 26px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    padding: 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
}

td {
    padding: 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

tr:hover {
    background: var(--bg-secondary);
}

tr:last-child td {
    border-bottom: none;
}

.empty-state {
    text-align: center;
    padding: 48px 16px !important;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ==================== STATUS BADGES ==================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-pending {
    background: var(--warning-light);
    color: #92400e;
}

.status-approved,
.status-confirmed {
    background: var(--secondary-light);
    color: #065f46;
}

.status-rejected,
.status-cancelled {
    background: var(--danger-light);
    color: #7f1d1d;
}

.status-ordered,
.status-shipped {
    background: var(--info-light);
    color: #1e40af;
}

.status-partially_received {
    background: #fef3c7;
    color: #92400e;
}

.status-delivered,
.status-closed {
    background: #dcfce7;
    color: #15803d;
}

.status-draft {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.status-low {
    background: var(--info-light);
    color: var(--primary);
}

.status-medium {
    background: var(--warning-light);
    color: #92400e;
}

.status-high {
    background: var(--danger-light);
    color: var(--danger);
}

.status-urgent {
    background: #fecaca;
    color: #7f1d1d;
}

/* ==================== FORMS ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    margin: 0 auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
}

.modal-header .close {
    border: none;
    background: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all 0.3s ease;
}

.modal-header .close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

form {
    padding: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* ==================== ACTIONS ==================== */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    border: none;
    border-radius: var(--radius-lg);
    font-size: 11px;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.action-btn.edit {
    background: var(--info-light);
    color: var(--primary);
}

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

.action-btn.delete {
    background: var(--danger-light);
    color: var(--danger);
}

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

.action-btn.view {
    background: var(--secondary-light);
    color: var(--secondary);
}

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

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .navbar {
        gap: 12px;
        padding: 12px 16px;
    }

    .navbar-brand {
        font-size: 18px;
        margin-right: 0;
    }

    .navbar-menu {
        flex-basis: 100%;
        order: 3;
        flex-wrap: wrap;
    }

    .navbar-user {
        flex-basis: 100%;
        order: 4;
        margin-left: 0;
        justify-content: space-between;
    }

    .page-header {
        flex-direction: column;
    }

    .metric-strip {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 12px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .table-wrapper {
        font-size: 12px;
    }

    th,
    td {
        padding: 12px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
        margin: 16px auto 20px;
    }

    .page-header-content h1 {
        font-size: 24px;
    }

    .navbar-menu {
        gap: 4px;
    }

    .navbar-menu a {
        padding: 8px 10px;
        font-size: 12px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-card .value {
        font-size: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .search-box {
        min-width: 100%;
    }
}

/* ==================== REQUESTS TABLE & BADGES ==================== */
.requests-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.requests-table thead {
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
}

.requests-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

.requests-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.requests-table tbody tr:hover {
    background: var(--bg-secondary);
}

.requests-table td {
    padding: 12px;
    color: var(--text-primary);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.priority-high {
    background: #fee2e2;
    color: #991b1b;
}

.badge.priority-medium {
    background: #fef3c7;
    color: #92400e;
}

.badge.priority-low {
    background: #e0f2fe;
    color: #0c4a6e;
}

#pendingBadge {
    background: #ef4444 !important;
    color: white !important;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-left: 5px;
}

/* Modals are centered by the .modal flex container on all screen sizes */
