/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #0F172A;
    --accent-color: #3B82F6;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 40px;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-links li {
    margin-bottom: 4px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94A3B8;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
}

.nav-links a:hover,
.nav-links a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, transparent 100%);
    color: white;
}

.nav-links a.active {
    border-left: 3px solid var(--accent-color);
}

.nav-links a svg {
    width: 18px;
    height: 18px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px;
    margin-left: 260px;
    overflow-y: auto;
    min-height: 100vh;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 10px 18px;
    border-radius: 24px;
    box-shadow: var(--shadow);
}

/* Cards & Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #E2E8F0;
    color: var(--text-primary);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    margin-right: 8px;
}

.btn-sm {
    background-color: #F1F5F9;
    border: 1px solid #E2E8F0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover {
    background-color: #E2E8F0;
}

.btn-danger-sm {
    background-color: #FEE2E2;
    border-color: #FECACA;
    color: #DC2626;
}

.btn-danger-sm:hover {
    background-color: #FECACA;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: #F1F5F9;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon.btn-danger:hover {
    background-color: #FEE2E2;
    color: #DC2626;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #E2E8F0;
}

.data-table th {
    background-color: #F8FAFC;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:hover {
    background-color: #F8FAFC;
}

.data-table td {
    font-size: 14px;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.raw_material {
    background: #DCFCE7;
    color: #166534;
}

.badge.packing_material {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge.finished_good {
    background: #FEF3C7;
    color: #92400E;
}

.badge.active {
    background: #DCFCE7;
    color: #166534;
}

.badge.exhausted {
    background: #FEE2E2;
    color: #DC2626;
}

.badge.role-super-admin {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
    color: white;
}

.badge.role-inventory {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge.role-grinding {
    background: #FEF3C7;
    color: #92400E;
}

.badge.role-dispatch {
    background: #DCFCE7;
    color: #166534;
}

.badge.role-distribution {
    background: #CFFAFE;
    color: #0891B2;
}

/* Cards */
.vendor-card,
.section-card {
    border: 1px solid #E2E8F0;
    padding: 20px;
    border-radius: 12px;
    background: white;
    transition: all 0.2s;
}

.vendor-card:hover,
.section-card:hover {
    box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1);
    transform: translateY(-2px);
}

.vendor-card h3,
.section-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.vendor-card p,
.section-card p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.tag {
    background: #E2E8F0;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Modals & Forms */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    animation: modalSlide 0.3s ease;
}

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

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

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

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

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input[readonly] {
    background-color: #F1F5F9;
    color: var(--text-secondary);
}

.form-group input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 4px;
    border-radius: 8px;
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F8FAFC;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
}

.scrollable-checks {
    max-height: 150px;
    overflow-y: auto;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
    margin: 0;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-color);
}

/* Image Upload */
.image-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* Text helpers */
.text-danger {
    color: var(--danger);
    font-weight: 600;
}

.form-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 16px 8px;
    }

    .brand {
        font-size: 0;
    }

    .brand svg {
        margin: 0 auto;
    }

    .nav-links a span {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 16px;
    }

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

/* Received Orders Module */
.orders-header {
    margin-bottom: 24px;
}

.orders-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.order-card {
    padding: 20px;
    border-left: 4px solid var(--accent-color);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #E2E8F0;
}

.order-info h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    margin-bottom: 8px;
}

.order-info h3 i {
    width: 20px;
    height: 20px;
    color: var(--accent-color);
}

.order-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.order-meta .badge {
    background: #DBEAFE;
    color: #1D4ED8;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

.order-total {
    text-align: right;
}

.order-total .total-label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.order-total .total-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--success);
}

.order-total .item-count {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.order-items h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.order-items h4 i {
    width: 16px;
    height: 16px;
}

.order-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #F8FAFC;
    border-radius: 8px;
    margin-bottom: 8px;
}

.item-photo-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #E2E8F0;
    transition: transform 0.2s, border-color 0.2s;
}

.item-photo-thumb:hover {
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.no-photo {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #E2E8F0;
    border-radius: 8px;
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
}

.order-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-item-details strong {
    font-size: 15px;
}

.order-item-details span {
    font-size: 13px;
    color: var(--text-secondary);
}

.bill-photo-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #E2E8F0;
}

.bill-photo-section h4 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.bill-photo-thumb {
    max-width: 200px;
    max-height: 150px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid #E2E8F0;
    transition: transform 0.2s;
}

.bill-photo-thumb:hover {
    transform: scale(1.02);
}

.discount-note {
    margin-top: 12px;
    padding: 8px 12px;
    background: #FEF3C7;
    color: #92400E;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* Photo Modal */
.photo-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.photo-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.photo-modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.photo-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
}

.photo-modal-close:hover {
    color: #EF4444;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state h3 {
    margin-top: 16px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    margin-top: 8px;
}

.loading-text {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.error-message {
    background: #FEE2E2;
    color: #991B1B;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}