/* ═══════════════════════════════════════
   VWorld Food — Admin Panel
   Shared stylesheet
   ═══════════════════════════════════════ */

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

:root {
    --brand:     #4DCCBE;
    --brand-lt:  #E8F9F7;
    --brand-mid: #A8E8E2;
    --brand-dk:  #2EA89D;
    --bg:        #F5F7F6;
    --surface:   #FFFFFF;
    --border:    rgba(0,0,0,0.07);
    --text-1:    #131815;
    --text-2:    #52615D;
    --text-3:    #96A8A3;
    --danger-bg: #FEF2F2;
    --danger:    #DC2626;
    --success-bg:#F0FDF9;
    --success:   #059669;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --font:      'DM Sans', sans-serif;
    --shadow:    0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.06);
}

html, body {
    min-height: 100vh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-1);
}

/* ── Animations ── */
@keyframes fadeLeft  { from { opacity:0; transform:translateX(-16px); } to { opacity:1; transform:translateX(0); } }
@keyframes fadeRight { from { opacity:0; transform:translateX(16px);  } to { opacity:1; transform:translateX(0); } }
@keyframes fadeUp    { from { opacity:0; transform:translateY(12px);  } to { opacity:1; transform:translateY(0); } }

/* ── Flash alerts ── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    display: flex; align-items: flex-start; gap: 8px;
}
.alert-danger, .alert-error { background:var(--danger-bg);  color:var(--danger);  border:1px solid rgba(220,38,38,.15); }
.alert-success              { background:var(--success-bg); color:var(--success); border:1px solid rgba(5,150,105,.15); }
.alert-warning              { background:#FFFBEB; color:#92400E; border:1px solid rgba(146,64,14,.12); }
.alert-info                 { background:var(--brand-lt); color:var(--brand-dk); border:1px solid rgba(77,204,190,.2); }

/* ══════════════════════════════
   LOGIN PAGE
   ══════════════════════════════ */

.login-bg::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 10% 90%, rgba(77,204,190,0.10) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 90% 10%, rgba(77,204,190,0.07) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.login-page {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

/* Left branding */
.login-left {
    padding: 48px 52px;
    display: flex; flex-direction: column; justify-content: space-between;
    border-right: 1px solid var(--border);
    background: var(--surface);
    animation: fadeLeft .5s ease both;
}

.logo-wrap  { display:flex; align-items:center; gap:12px; margin-bottom:52px; }
.logo-mark  { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; }
.logo-mark img { width:36px; height:36px; object-fit:contain; }
.logo-name  { font-size:15px; font-weight:600; color:var(--text-1); letter-spacing:-0.01em; }

.left-headline { font-size:28px; font-weight:500; line-height:1.25; color:var(--text-1); letter-spacing:-0.02em; }
.left-sub      { font-size:13px; color:var(--text-2); line-height:1.65; margin-top:12px; }

.left-footer   { display:flex; flex-direction:column; gap:10px; }
.status-pill   {
    display:inline-flex; align-items:center; gap:8px;
    padding:7px 13px;
    border:1px solid var(--border); border-radius:40px;
    font-size:12px; color:var(--text-2);
    width:fit-content; background:var(--bg);
}
.status-dot      { width:7px; height:7px; border-radius:50%; background:var(--brand); }
.status-dot.info { background:var(--brand-mid); }

/* Right form */
.login-right {
    padding: 48px 52px;
    display: flex; flex-direction: column; justify-content: center;
    background: var(--bg);
    animation: fadeRight .5s .1s ease both;
    position: relative;
}

/* Language switcher */
.lang-switcher {
    position: absolute; top: 24px; right: 28px;
    display: flex; gap: 4px;
}
.lang-btn {
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    font-family: var(--font); font-size: 12px; color: var(--text-3);
    cursor: pointer; transition: all .15s;
}
.lang-btn:hover   { color: var(--text-1); border-color: var(--brand-mid); }
.lang-btn.active  { background: var(--surface); color: var(--text-1); border-color: var(--brand); font-weight: 500; }

.form-header   { margin-bottom:32px; }
.form-title    { font-size:22px; font-weight:500; color:var(--text-1); letter-spacing:-0.02em; }
.form-sub      { font-size:13px; color:var(--text-3); margin-top:5px; }

.field         { margin-bottom:18px; }
.field-label   {
    display:flex; justify-content:space-between; align-items:center;
    font-size:12px; font-weight:500; color:var(--text-2);
    letter-spacing:.02em; margin-bottom:7px;
}
.field-input {
    width:100%; padding:10px 14px;
    border:1px solid var(--border); border-radius:var(--radius-sm);
    background:var(--surface);
    font-family:var(--font); font-size:14px; color:var(--text-1);
    outline:none; transition:border-color .15s, box-shadow .15s;
}
.field-input::placeholder { color:var(--text-3); }
.field-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(77,204,190,.18);
}

.btn-login {
    width:100%; padding:11px 16px;
    border:none; border-radius:var(--radius-sm);
    background:var(--text-1); color:var(--surface);
    font-family:var(--font); font-size:14px; font-weight:500;
    cursor:pointer; letter-spacing:.01em;
    display:flex; align-items:center; justify-content:center; gap:8px;
    transition:background .15s, transform .1s;
    margin-top:6px;
    position:relative; overflow:hidden;
}
.btn-login::after {
    content:'';
    position:absolute; bottom:0; left:0; right:0;
    height:2px; background:var(--brand);
    border-radius:0 0 var(--radius-sm) var(--radius-sm);
    opacity:0; transition:opacity .15s;
}
.btn-login:hover        { background:#2a3330; }
.btn-login:hover::after { opacity:1; }
.btn-login:active       { transform:scale(.99); }

.form-note {
    margin-top:20px; display:flex; align-items:center; gap:6px;
    font-size:11px; color:var(--text-3);
    border-top:1px solid var(--border); padding-top:16px;
}

/* ══════════════════════════════
   MAIN / DASHBOARD PAGE
   ══════════════════════════════ */

.topbar {
    height:56px;
    background:var(--surface);
    border-bottom:1px solid var(--border);
    display:flex; align-items:center; justify-content:space-between;
    padding:0 28px;
    position:sticky; top:0; z-index:100;
}
.topbar-left  { display:flex; align-items:center; gap:12px; }
.tb-logo-mark { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; }
.tb-logo-mark img { width:28px; height:28px; object-fit:contain; }
.tb-name      { font-size:14px; font-weight:600; color:var(--text-1); letter-spacing:-0.01em; }
.tb-sep       { width:1px; height:18px; background:var(--border); margin:0 4px; }
.tb-sub       { font-size:13px; color:var(--text-3); }
.topbar-right { display:flex; align-items:center; gap:14px; }

.user-chip    { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-2); }
.avatar {
    width:30px; height:30px; border-radius:50%;
    background:var(--brand-lt); border:1.5px solid var(--brand-mid);
    display:flex; align-items:center; justify-content:center;
    font-size:11px; font-weight:600; color:var(--brand-dk);
}
.btn-exit {
    display:flex; align-items:center; gap:6px;
    padding:6px 13px;
    border:1px solid var(--border); border-radius:var(--radius-sm);
    background:transparent;
    font-family:var(--font); font-size:12px; color:var(--text-2);
    cursor:pointer; transition:background .15s, color .15s;
    text-decoration:none;
}
.btn-exit:hover { background:#FEF2F2; color:#DC2626; border-color:rgba(220,38,38,.2); }

.main-content {
    max-width:860px; margin:0 auto;
    padding:40px 28px 60px;
    animation:fadeUp .4s ease both;
}
.section-label {
    font-size:11px; font-weight:500; color:var(--text-3);
    letter-spacing:.07em; text-transform:uppercase;
    margin-bottom:14px;
}
.page-hello     { font-size:22px; font-weight:500; color:var(--text-1); letter-spacing:-0.02em; }
.page-hello span{ color:var(--brand-dk); }
.page-sub       { font-size:13px; color:var(--text-3); margin-top:5px; }

.tools-grid {
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(220px,1fr));
    gap:14px; margin-bottom:36px;
}
.tool-card {
    background:var(--surface); border:1px solid var(--border);
    border-radius:var(--radius-lg); padding:22px;
    text-decoration:none; color:inherit;
    display:flex; flex-direction:column;
    transition:box-shadow .18s, border-color .18s, transform .15s;
    position:relative; overflow:hidden;
}
.tool-card::after {
    content:''; position:absolute; left:0; top:0; bottom:0;
    width:3px; border-radius:var(--radius-lg) 0 0 var(--radius-lg);
    background:var(--brand); opacity:0; transition:opacity .18s;
}
.tool-card:hover { box-shadow:var(--shadow); border-color:var(--brand-mid); transform:translateY(-2px); }
.tool-card:hover::after { opacity:1; }

.tool-icon { width:40px; height:40px; border-radius:10px; background:var(--brand-lt); display:flex; align-items:center; justify-content:center; margin-bottom:16px; }
.tool-icon svg { width:20px; height:20px; stroke:var(--brand-dk); }
.tool-icon.db   { background:#EFF6FF; }
.tool-icon.db svg { stroke:#3B82F6; }

.tool-name  { font-size:15px; font-weight:500; color:var(--text-1); margin-bottom:5px; }
.tool-desc  { font-size:12px; color:var(--text-3); line-height:1.55; flex:1; }
.tool-arrow { margin-top:18px; font-size:12px; color:var(--brand-dk); display:flex; align-items:center; gap:5px; font-weight:500; }
.tool-arrow svg { transition:transform .15s; }
.tool-card:hover .tool-arrow svg { transform:translateX(3px); }

.recent-card  { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); overflow:hidden; }
.recent-head  { padding:16px 20px; border-bottom:1px solid var(--border); font-size:13px; font-weight:500; color:var(--text-1); }
.recent-row   { display:flex; align-items:center; gap:13px; padding:12px 20px; border-bottom:1px solid var(--border); transition:background .12s; }
.recent-row:last-child { border-bottom:none; }
.recent-row:hover { background:var(--bg); }
.recent-ic    { width:30px; height:30px; border-radius:8px; background:var(--brand-lt); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.recent-ic svg { width:14px; height:14px; stroke:var(--brand-dk); }
.recent-ic.db  { background:#EFF6FF; }
.recent-ic.db svg { stroke:#3B82F6; }
.recent-name  { font-size:13px; font-weight:500; color:var(--text-1); }
.recent-time  { font-size:11px; color:var(--text-3); margin-top:1px; }
.badge { font-size:10px; font-weight:500; padding:3px 9px; border-radius:20px; background:#F0FDF9; color:#059669; border:1px solid rgba(5,150,105,.12); margin-left:auto; }

/* ── Responsive ── */
@media (max-width:700px) {
    .login-page  { grid-template-columns:1fr; }
    .login-left  { display:none; }
    .login-right { padding:40px 28px; justify-content:flex-start; padding-top:60px; }
    .topbar      { padding:0 16px; }
    .tb-sep, .tb-sub { display:none; }
    .main-content { padding:28px 16px 48px; }
    .tools-grid  { grid-template-columns:1fr; }
}

/* ══════════════════════════════
   CALCULATOR PAGE
   ══════════════════════════════ */

.app-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 28px 60px;
    animation: fadeUp .4s ease both;
}

/* ── Header ── */
.app-container header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.app-container header h1 {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-1);
    letter-spacing: -0.02em;
    flex: 1;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
    text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.back-button:hover { background: var(--bg); color: var(--text-1); }

.theme-toggle {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

/* ── Connection status ── */
#connection-status {
    position: fixed; top: 64px; right: 16px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-family: var(--font);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-3);
    z-index: 99;
}

/* ── Form layout ── */
.calculator-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.calculator-form > .calculate-btn {
    grid-column: 1 / -1;
}

/* right column: Logistics + Shipment stacked */
.form-section-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    letter-spacing: -0.01em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

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

.form-group label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.02em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text-1);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%2396A8A3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(77,204,190,.15);
    background: var(--surface);
}

.form-group input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* inline button inside form-group (e.g. Update Exchange Rates) */
.form-group button {
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--font);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: background .15s, border-color .15s;
    align-self: flex-start;
}
.form-group button:hover { background: var(--brand-lt); border-color: var(--brand-mid); color: var(--brand-dk); }

/* ── Calculate button ── */
.calculate-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--text-1);
    color: var(--surface);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: background .15s, transform .1s;
    position: relative; overflow: hidden;
}
.calculate-btn::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0;
    height: 2px; background: var(--brand);
    opacity: 0; transition: opacity .15s;
}
.calculate-btn:hover        { background: #2a3330; }
.calculate-btn:hover::after { opacity: 1; }
.calculate-btn:active       { transform: scale(.99); }

/* ── Results ── */
.results-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 20px;
}
.results-section h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.result-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result-item.total {
    grid-column: 1 / -1;
    background: var(--brand-lt);
    border-color: var(--brand-mid);
}
.result-item .label {
    font-size: 11px;
    color: var(--text-3);
    letter-spacing: 0.02em;
}
.result-item .value {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
}
.result-item.total .value { color: var(--brand-dk); }

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.action-btn:hover { background: var(--brand-lt); border-color: var(--brand-mid); color: var(--brand-dk); }

.hidden { display: none !important; }

/* ── Notification ── */
#notification-container {
    position: fixed;
    bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 300;
}

/* ── Responsive calculator ── */
@media (max-width: 700px) {
    .calculator-form { grid-template-columns: 1fr; }
    .results-grid    { grid-template-columns: 1fr; }
    .result-item.total { grid-column: 1; }
    .app-container   { padding: 20px 16px 48px; }
}

#port-expense-options {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 4px;
}

#port-expense-options strong {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 10px 0 8px;
    display: block;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.port-expense-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    transition: background .12s;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.port-expense-item:hover { background: var(--bg); }

.port-expense-item input[type="checkbox"] {
    width: 16px; height: 16px;
    min-width: 16px;
    margin-top: 1px;
    accent-color: var(--brand);
    cursor: pointer;
    pointer-events: auto;
    position: relative;
    z-index: 2;
}

.port-expense-item label {
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    line-height: 1.45;
    flex: 1;
    pointer-events: auto;
}

/* ══════════════════════════════
   JS-GENERATED: RESULTS
   (#result-section → displayResults())
   ══════════════════════════════ */

#result-section {
    margin-top: 28px;
}

#result-section h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-1);
    letter-spacing: -0.02em;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

#result-section .results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    align-items: start;
}

.result-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.result-section h4 {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.result-section:has(h4 strong) {
    grid-column: 1 / -1;
    background: var(--brand-lt);
    border-color: var(--brand-mid);
}
.result-section:has(h4 strong) h4 { color: var(--brand-dk); border-color: var(--brand-mid); }
.result-section:has(h4 strong) .result-item span:last-child { color: var(--brand-dk); font-size: 20px; font-weight: 600; }

.result-section:last-child { grid-column: 1 / -1; }

.result-section .result-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.result-section .result-item:last-child { border-bottom: none; padding-bottom: 2px; }

.result-section .result-item span:first-child {
    color: var(--text-2);
    flex: 1;
    line-height: 1.4;
}
.result-section .result-item span:last-child {
    color: var(--text-1);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: 13px;
}

/* ── Notifications ── */
.notification {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    box-shadow: var(--shadow);
    animation: fadeUp .2s ease both;
    max-width: 300px;
}
.notification.success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(5,150,105,.15); }
.notification.error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid rgba(220,38,38,.15); }
.notification.info    { background: var(--brand-lt);   color: var(--brand-dk);border: 1px solid rgba(77,204,190,.2); }

/* ── Form validation errors ── */
.error-message {
    font-size: 11px;
    color: var(--danger);
    margin-top: 3px;
}
input.error, select.error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important;
}

/* ── Responsive results ── */
@media (max-width: 700px) {
    #result-section .results-grid { grid-template-columns: 1fr; }
    .result-section:has(h4 strong),
    .result-section:last-child { grid-column: 1; }
    .form-section-stack { gap: 16px; }
    .calculator-form { grid-template-columns: 1fr; }
}
