:root {
    /* Main Theme Variables Mapping */
    --bg-color: #f8fafc;
    /* Slate 50 from main theme */
    --text-color: #1e293b;
    /* Slate 800 from main theme */
    --primary-color: #4f46e5;
    /* Indigo 600 from main theme */

    /* UI Variables */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --card-bg: #ffffff;
    --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: 8px;
}

body {
    /* Inherit font from main styles.css (Inter) */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    /* Allow scrolling instead of fixed height */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex: 1;
    /* Take remaining space */
    width: 100%;
    background-color: var(--bg-color);
    /* overflow: hidden; Removed to allow scrolling */
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    /* overflow-y: auto; Removed internal scroll */
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

/* Main Content Styles */
.calendar-main {
    flex-grow: 1;
    padding: 32px;
    /* overflow-y: auto; Removed internal scroll */
    display: flex;
    flex-direction: column;
}

.instruction {
    font-size: 0.9rem;
    color: #64748b;
    /* Slate 500 */
    margin-bottom: 24px;
    font-style: normal;
}

.supplier-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.supplier-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.supplier-card:active {
    cursor: grabbing;
}

.supplier-card h3 {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.supplier-card p {
    margin: 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
}

/* Main Content Styles */
.calendar-main {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

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

h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    text-transform: capitalize;
}

button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background: #4338ca;
    /* Indigo 700 */
    box-shadow: var(--shadow-md);
}

.legend {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    font-size: 0.9rem;
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-weight: 500;
}

.badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }

    body,
    .app-container,
    .calendar-main {
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .calendar-main {
        width: 100% !important;
    }

    .calendar-header {
        justify-content: center !important;
        margin-bottom: 15px !important;
    }

    .calendar-header h1 {
        font-size: 1.5rem !important;
    }

    .calendar {
        border: 1px solid #000 !important;
        background: #000 !important;
        /* Ensure grid lines are visible */
        width: 100% !important;
        grid-template-rows: auto repeat(6, 1fr) !important;
        /* Force heights */
        min-height: 90vh !important;
    }

    .day-name {
        background: #eee !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        padding: 8px !important;
        font-size: 0.8rem !important;
    }

    .day {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        min-height: 80px !important;
        /* Ensure content doesn't break poorly */
        page-break-inside: avoid;
    }

    .day.other-month {
        background: #f9f9f9 !important;
        color: #ccc !important;
    }

    .event {
        border-radius: 2px !important;
        padding: 2px 4px !important;
        font-size: 0.7rem !important;
        margin-bottom: 1px !important;
        color: #000 !important;
        /* Force text to be black for readability */
        border: 1px solid rgba(0, 0, 0, 0.1) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .legend {
        padding: 8px !important;
        margin-bottom: 10px !important;
        border: 1px solid #ddd !important;
        background: #fff !important;
    }

    .legend-item {
        font-size: 0.75rem !important;
    }

    .badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.no-print {
    /* Standard class for elements to hide during print */
}



.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color);
    /* Grid lines color */
    padding: 1px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    flex-grow: 1;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.day-name {
    text-align: center;
    font-weight: 600;
    color: #64748b;
    padding: 16px;
    background: #f1f5f9;
    /* Slate 100 */
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.day {
    min-height: 120px;
    background: var(--card-bg);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: background-color 0.2s;
}

.day.empty {
    background: #f8fafc;
}

.day.today {
    background-color: #eef2ff;
    /* Indigo 50 */
}

.day.today .date-number {
    color: var(--primary-color);
    background: #e0e7ff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day.drag-over {
    background-color: #e0e7ff;
}

.date-number {
    font-weight: 600;
    margin-bottom: 8px;
    pointer-events: none;
    color: var(--text-color);
    font-size: 0.95rem;
}

.event {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    text-align: left;
    cursor: default;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-bottom: 4px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.1s;
}

.event:hover {
    transform: scale(1.02);
    z-index: 5;
}

/* Style for Deadlines/Warnings */
.event.deadline {
    background-color: var(--card-bg) !important;
    border: 1px solid;
    font-weight: 700;
    box-shadow: none;
}



@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
        box-sizing: border-box;
    }

    .suppliers-list {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding-bottom: 8px;
    }

    .supplier-card {
        min-width: 220px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .calendar-main {
        height: auto;
        padding: 16px;
    }

    .calendar {
        display: flex;
        flex-direction: column;
        gap: 8px;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .day-name {
        display: none;
    }

    .day {
        min-height: auto;
        border: 1px solid var(--border-color);
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
    }

    .day.empty {
        display: none;
    }
}

/* Holiday Styling */
.day.holiday {
    background-color: #fff1f2;
    /* Light Red background */
}

.day.holiday .date-number {
    color: #e11d48;
    /* Red text for date number */
    font-weight: 700;
}

.holiday-name {
    font-size: 0.75rem;
    color: #e11d48;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
}

/* Ensure today highlight takes precedence over holiday background if needed, 
   or mix them. Let's make today border more prominent if it's also a holiday. */
.day.today.holiday {
    background-color: #fff1f2;
    /* Keep holiday background or mix */
    border: 2px solid var(--primary-color);
    /* Emphasize today */
}

/* --- Dynamic Supplier UI --- */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.sidebar-header h2 {
    margin: 0;
}

.btn-icon {
    background: transparent;
    color: var(--primary-color);
    border: none;
    font-size: 1.4rem;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #4338ca;
    transform: scale(1.15) rotate(90deg);
}

.suppliers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.supplier-card {
    position: relative;
    padding-right: 48px;
    border-left: 5px solid var(--supp-color, #cbd5e1);
}

.card-actions {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.supplier-card:hover .card-actions {
    opacity: 1;
}

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: white;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.action-btn.delete:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.close-modal {
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #1e293b;
}

#supplierForm {
    padding: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 44px;
    height: 44px;
    cursor: pointer;
    background: none;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 10px;
}

#colorHex {
    font-family: monospace;
    font-weight: 600;
    color: #64748b;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

#cancelModal,
.btn-secondary,
.btn-primary {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary,
#cancelModal {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover,
#cancelModal:hover {
    background: #e2e8f0;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}