/* --- Admin Panel Stylesheet (Simplified & Modern) --- */
:root {
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Dark Theme Core */
    --color-bg: #0D1117;           /* Main Background */
    --color-panel: #161B22;        /* Cards/Tables */
    --color-border: #30363D;       /* Subtle Borders */
    
    /* Text */
    --color-text-main: #E6EDF3;
    --color-text-muted: #8B949E;
    
    /* Actions */
    --color-brand: #BEF264;        /* Bright Lime (High Visibility) */
    --color-brand-text: #0D1117;   /* Text on Lime */
    --color-danger: #F85149;       /* Red for Delete */
    --color-input-bg: #0D1117;     /* Input Background */

    --radius: 12px;
    --spacing: 1.5rem;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg);
    color: var(--color-text-main);
    margin: 0;
    line-height: 1.5;
    font-size: 16px; /* Larger base font size */
}

/* --- Page Visibility Logic --- */
.page, .admin-content { display: none; }
.page.active, .admin-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Login Page (Centralized & Clean) --- */
.admin-login-container { 
    min-height: 100vh; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 1rem;
    background: radial-gradient(circle at center, #1c232e 0%, #0d1117 100%);
}

.login-card { 
    width: 100%; 
    max-width: 420px; 
    background-color: var(--color-panel); 
    padding: 3rem; 
    border-radius: var(--radius); 
    border: 1px solid var(--color-border); 
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    text-align: center;
}

.login-card h1 { margin-bottom: 2rem; font-size: 1.8rem; }
.login-card label { text-align: left; display: block; margin-bottom: 0.5rem; color: var(--color-text-muted); }

/* --- Dashboard Container --- */
.admin-panel-container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 2rem; 
}

/* Header Area */
.panel-header { 
    display: flex; 
    flex-direction: column; 
    gap: 1rem; 
    margin-bottom: 2rem; 
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
}
@media(min-width: 768px) {
    .panel-header { flex-direction: row; justify-content: space-between; align-items: center; }
}

.panel-header h1 { margin: 0; font-size: 2rem; }

/* --- Big Friendly Tabs --- */
.admin-tabs { 
    display: flex; 
    gap: 1rem; 
    margin-bottom: 2rem; 
    background: var(--color-panel);
    padding: 0.5rem;
    border-radius: var(--radius);
    width: fit-content;
}

.admin-tab { 
    background: transparent; 
    border: none; 
    padding: 0.8rem 2rem; 
    cursor: pointer; 
    color: var(--color-text-muted); 
    font-weight: 600; 
    font-size: 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.admin-tab:hover { color: var(--color-text-main); background: rgba(255,255,255,0.05); }
.admin-tab.active { 
    background: var(--color-brand); 
    color: var(--color-brand-text); 
    box-shadow: 0 4px 12px rgba(190, 242, 100, 0.2);
}

/* --- Simplified Tables --- */
.table-container { 
    background-color: var(--color-panel); 
    border-radius: var(--radius); 
    border: 1px solid var(--color-border); 
    overflow: hidden; 
    overflow-x: auto;
}

.admin-table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 800px; 
}

.admin-table th { 
    background-color: rgba(255,255,255,0.03); 
    padding: 1.2rem 1rem; 
    text-align: left; 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    color: var(--color-text-muted);
    font-weight: 700;
}

.admin-table td { 
    padding: 1.2rem 1rem; 
    border-bottom: 1px solid var(--color-border); 
    color: var(--color-text-main);
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover { background-color: rgba(255,255,255,0.02); }

/* --- Form Inputs (Big & Clear) --- */
.form-input { 
    width: 100%; 
    padding: 1rem; 
    background-color: var(--color-input-bg); 
    border: 1px solid var(--color-border); 
    border-radius: 8px; 
    color: var(--color-text-main); 
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box; 
}

.form-input:focus { 
    outline: none; 
    border-color: var(--color-brand); 
    box-shadow: 0 0 0 2px rgba(190, 242, 100, 0.1); 
}

label { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.5rem; display: block; color: var(--color-text-main); }

/* --- Buttons --- */
.btn { 
    padding: 0.8rem 1.5rem; 
    border: none; 
    border-radius: 8px; 
    font-weight: 700; 
    cursor: pointer; 
    display: inline-flex; 
    align-items: center; 
    gap: 0.5rem; 
    text-decoration: none; 
    font-size: 1rem;
    transition: transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background-color: var(--color-brand); color: var(--color-brand-text); }
.btn-primary:hover { background-color: #a8db50; }

.btn-secondary { background-color: transparent; border: 1px solid var(--color-border); color: var(--color-text-main); }
.btn-secondary:hover { background-color: rgba(255,255,255,0.05); }

.table-actions button {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.5rem;
    transition: color 0.2s;
}
.table-actions button:hover { color: var(--color-text-main); }
.table-actions button:nth-child(2):hover { color: var(--color-danger); }

/* --- Modal (Pop-up) Fixed Scroll --- */
.modal { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background-color: rgba(0, 0, 0, 0.85); 
    backdrop-filter: blur(5px);
    z-index: 1000; 
    align-items: center; 
    justify-content: center; 
    padding: 1rem;
}

.modal.flex { display: flex; }

.modal-content { 
    background-color: var(--color-panel); 
    border: 1px solid var(--color-border); 
    border-radius: var(--radius); 
    width: 100%; 
    max-width: 900px; 
    max-height: 90vh; /* Max height limited to view */
    display: flex; 
    flex-direction: column; 
    box-shadow: 0 50px 100px -20px rgba(0,0,0,0.5);
    overflow: hidden; /* Contains the form */
}

.modal-header { 
    padding: 1.5rem 2rem; 
    border-bottom: 1px solid var(--color-border); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background-color: var(--color-panel);
    z-index: 10;
}
.modal-header h2 { margin: 0; font-size: 1.5rem; }

.close-modal-btn { background: none; border: none; font-size: 2rem; color: var(--color-text-muted); cursor: pointer; }
.close-modal-btn:hover { color: var(--color-text-main); }

/* CRITICAL FIX: Form Flex Logic */
#shipment-form {
    display: flex;
    flex-direction: column;
    flex: 1;           /* Takes all remaining space */
    min-height: 0;     /* Allows nested scrolling to work */
    overflow: hidden;  /* Keeps content inside */
}

.modal-body { 
    padding: 2rem; 
    overflow-y: auto;  /* ENABLES SCROLLING HERE */
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 2rem; 
}

.modal-footer { 
    padding: 1.5rem 2rem; 
    border-top: 1px solid var(--color-border); 
    display: flex; 
    justify-content: flex-end; 
    gap: 1rem; 
    background-color: rgba(0,0,0,0.2);
    z-index: 10;
}

/* Modal Grids & Sections */
.form-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 1.5rem; 
}
@media(min-width: 768px) { .form-grid { grid-template-columns: 1fr 1fr; } }

.dynamic-section { 
    background-color: rgba(0,0,0,0.2); 
    padding: 1.5rem; 
    border-radius: 8px; 
    border: 1px solid var(--color-border);
}
.dynamic-section h3 { margin-top: 0; color: var(--color-brand); font-size: 1.1rem; border-bottom: 1px solid var(--color-border); padding-bottom: 0.5rem; margin-bottom: 1rem; }

.item-list { margin-bottom: 1rem; }
.list-item { 
    display: flex; 
    justify-content: space-between; 
    padding: 0.8rem; 
    background: var(--color-bg); 
    margin-bottom: 0.5rem; 
    border-radius: 4px;
    align-items: center;
}
.remove-item-btn { color: var(--color-danger); font-size: 1.5rem; line-height: 1; background: none; border: none; cursor: pointer; }

/* Password Toggle */
.password-wrapper { position: relative; }
#toggle-password { position: absolute; right: 1rem; top: 3.2rem; cursor: pointer; color: var(--color-text-muted); }