/**
 * apple-style.css — Refactor giao diện theo phong cách Apple-like
 *   - Phẳng, pastel, typography lớn, pill tabs
 *   - Apple light gray background, white rounded cards với soft shadow
 *   - Load CUỐI CÙNG để override base.css + components.css + tooltip.css
 */

/* ============================================================
   FOUNDATION — Background, typography, container
   ============================================================ */
/* Inter font với Vietnamese subset → render dấu tiếng Việt đẹp trên cả Win/Mac.
   display=swap → text vẫn hiện ngay khi font đang tải (không bị blank). */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap&subset=vietnamese');

/* ============================================================
   FONT STACK CHUẨN — dùng xuyên suốt phần mềm
   • UI text:  Inter → Segoe UI (Win) → SF Pro (Mac) → Roboto (Linux)
   • Mono:     Consolas (Win) → SF Mono/Menlo (Mac) → Cascadia (Win 11)
   • Math:     Cambria Math (Win/Mac) → Georgia → Times New Roman
   ============================================================ */
:root {
    --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', Consolas, 'Liberation Mono', Menlo, Monaco, 'Courier New', monospace;
    --font-math: 'Cambria Math', 'STIX Two Math', Georgia, 'Times New Roman', serif;
}

body {
    background: #f5f5f7 !important;
    font-family: var(--font-ui) !important;
    color: #1d1d1f !important;
    padding: 32px 16px !important;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Đảm bảo MỌI element kế thừa font UI (input/select/textarea HTML mặc định không kế thừa) */
input, select, textarea, button {
    font-family: var(--font-ui);
}

/* Đồng bộ monospace cho code, formula, pre — Consolas chuẩn trên Windows */
code, kbd, pre, samp, .formula {
    font-family: var(--font-mono) !important;
}

.container {
    max-width: 1240px !important;
    margin: 0 auto;
}

/* ============================================================
   APP TOOLBAR — Apple-style top bar (logo + title + actions)
   ============================================================ */
.app-toolbar {
    background: white;
    border-radius: 14px;
    padding: 14px 22px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
}
.app-toolbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.app-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(2,132,199,0.3);
}
.app-title-block { min-width: 0; }
.app-title {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: #1d1d1f !important;
    margin: 0 !important;
    letter-spacing: -0.01em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-subtitle {
    font-size: 11.5px;
    color: #86868b;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Toolbar buttons */
.btn-toolbar {
    background: #f5f5f7;
    color: #1d1d1f;
    border: none;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, transform 0.08s;
}
.btn-toolbar:hover { background: #e8e8ed; }
.btn-toolbar:active { transform: scale(0.97); }
.btn-toolbar-primary {
    background: #0284c7;
    color: white;
    font-weight: 600;
}
.btn-toolbar-primary:hover { background: #0369a1; }
.btn-toolbar-icon {
    width: 38px; height: 38px;
    padding: 0;
    justify-content: center;
    color: #475569;
}
.btn-toolbar-icon:hover { color: #1d1d1f; }

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 12px 36px rgba(0,0,0,0.12);
    padding: 6px;
    z-index: 1000;
    display: none;
    border: 1px solid rgba(0,0,0,0.06);
}
.dropdown.open .dropdown-menu { display: block; animation: dropdownFade 0.15s ease-out; }
@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dropdown-menu-right { right: 0; left: auto; }

.dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-family: inherit;
    color: #1d1d1f;
    transition: background 0.1s;
}
.dropdown-item:hover { background: #f5f5f7; }
.dropdown-item-danger { color: #dc2626; }
.dropdown-item-danger:hover { background: #fef2f2; }
.dropdown-icon {
    font-size: 18px;
    line-height: 1;
    margin-top: 2px;
    flex-shrink: 0;
}
.dropdown-label {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
}
.dropdown-desc {
    font-size: 11.5px;
    color: #86868b;
    margin-top: 2px;
    line-height: 1.3;
}
.dropdown-divider {
    height: 1px;
    background: #e5e5ea;
    margin: 4px 8px;
}

/* Project info card — sau khi tách buttons khỏi section title */
.project-info-card {
    margin-bottom: 22px;
}

/* Save project bar — cuối workflow */
.save-project-bar {
    background: white;
    border-radius: 14px;
    padding: 18px 22px;
    margin: 18px 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    border: 1px solid rgba(2,132,199,0.12);
}

/* Project list inline (tab Dự án đã lưu) */
.project-list-item {
    background: white;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.project-list-item:hover {
    border-color: #0284c7;
    box-shadow: 0 2px 8px rgba(2,132,199,0.08);
}
.project-list-meta { min-width: 0; flex: 1; }
.project-list-name {
    font-size: 14.5px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-list-info {
    font-size: 12px;
    color: #86868b;
}
.project-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
.project-list-empty {
    padding: 40px 20px;
    text-align: center;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    color: #64748b;
}

/* ============================================================
   HEADER (cũ — ẩn khi có app-toolbar mới)
   ============================================================ */
.header { display: none !important; }

/* ============================================================
   HEADER — Apple-style centered title (legacy, không dùng nữa)
   ============================================================ */
.header {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 28px !important;
    text-align: center;
    border-radius: 0 !important;
}

.header h1 {
    font-size: clamp(22px, 4vw, 36px) !important;
    font-weight: 800 !important;
    color: #1d1d1f !important;
    letter-spacing: -0.02em;
    margin-bottom: 10px !important;
    line-height: 1.15;
}

.header .subtitle {
    font-size: 12px !important;
    color: #86868b !important;
    opacity: 1 !important;
    max-width: 760px;
    margin: 0 auto;
    line-height: 1.55;
}
.header .subtitle strong { color: #1d1d1f; font-weight: 600; }
.header .subtitle br { display: none; }
.header .subtitle .standards { display: block; margin-top: 4px; font-size: 11px; }

/* ============================================================
   TAB NAVIGATION — Pill style
   ============================================================ */
.tab-nav {
    background: #ffffff !important;
    border-bottom: none !important;
    border-radius: 999px !important;
    padding: 6px !important;
    margin: 24px auto 28px auto !important;
    display: inline-flex !important;
    gap: 4px !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);
    width: auto;
    justify-content: center;
}

/* Container để center tab-nav */
.tab-nav-wrapper {
    text-align: center;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 24px !important;
    background: transparent !important;
    color: #6e6e73 !important;
    border-radius: 999px !important;
    border: none !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    margin-bottom: 0 !important;
    transition: all 0.25s ease !important;
    box-shadow: none !important;
}

.tab-btn:hover:not(.active) {
    background: #f5f5f7 !important;
    color: #1d1d1f !important;
}

.tab-btn.active {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    color: white !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3) !important;
}

/* ============================================================
   CARDS — White rounded with soft shadow
   ============================================================ */
.card {
    background: #ffffff !important;
    border-radius: 18px !important;
    padding: 26px !important;
    margin-bottom: 16px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03) !important;
    border: 1px solid rgba(0,0,0,0.04);
}

.section-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #6e6e73 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
    margin-bottom: 20px !important;
    padding-bottom: 14px !important;
    border-bottom: 1px solid #f0f0f3 !important;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title .num {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    width: 28px !important;
    height: 28px !important;
    color: white !important;
    border-radius: 50% !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

/* ============================================================
   FORM FIELDS — Apple-style inputs
   ============================================================ */
.field label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #6e6e73 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    margin-bottom: 8px !important;
}

.field input, .field select, .field textarea {
    background: #ffffff !important;
    border: 1px solid #d2d2d7 !important;
    border-radius: 10px !important;
    padding: 0 14px !important;
    height: 44px !important;          /* CHIỀU CAO ĐỒNG ĐỀU */
    line-height: 44px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #1d1d1f !important;
    transition: all 0.2s !important;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;       /* xóa spinner Firefox */
}
.field textarea {
    height: auto !important;
    min-height: 100px !important;
    padding: 12px 14px !important;
    line-height: 1.5 !important;
}
/* Xóa spinner Chrome/Safari trên input number */
.field input[type=number]::-webkit-outer-spin-button,
.field input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
/* Custom dropdown arrow cho select (giữ tinh tế Apple) */
.field select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%236e6e73' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    padding-right: 36px !important;
    cursor: pointer;
}

.field input:focus, .field select:focus, .field textarea:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
    outline: none;
}

/* ============================================================
   BUTTONS — Pastel Apple-style
   ============================================================ */
.btn {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    border-radius: 12px !important;
    padding: 14px 26px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border: none !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25) !important;
    transition: all 0.2s !important;
    color: white;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35) !important;
}

.btn-primary { /* same as .btn */ }
.btn-export { background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important; box-shadow: 0 4px 14px rgba(22, 163, 74, 0.25) !important; }
.btn-export-excel { background: linear-gradient(135deg, #15803d 0%, #166534 100%) !important; }
.btn-secondary { background: #f5f5f7 !important; color: #1d1d1f !important; box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important; }
.btn-warning { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important; box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25) !important; }

/* Project actions buttons (header) — pastel */
.btn-mini {
    border-radius: 999px !important;
    padding: 8px 16px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    border: none !important;
    box-shadow: none !important;
    transition: all 0.2s !important;
}
.btn-save {
    background: #dbeafe !important;
    color: #1e40af !important;
}
.btn-save:hover { background: #bfdbfe !important; }

.btn-library {
    background: #fef3c7 !important;
    color: #92400e !important;
}
.btn-library:hover { background: #fde68a !important; }

.btn-load {
    background: #dcfce7 !important;
    color: #166534 !important;
}
.btn-load:hover { background: #bbf7d0 !important; }

.btn-reset {
    background: #fee2e2 !important;
    color: #991b1b !important;
}
.btn-reset:hover { background: #fecaca !important; }

/* ============================================================
   STEP CARDS — Apple-style accordion
   ============================================================ */
.step-cards-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border: none !important;
}

.step-cards-header {
    background: transparent !important;
    border: none !important;
    padding: 0 0 14px 0 !important;
    color: #1d1d1f !important;
}

.step-cards-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #6e6e73 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
}

.step-card {
    background: #ffffff !important;
    border-radius: 18px !important;
    border: 1px solid rgba(0,0,0,0.04) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(0,0,0,0.03) !important;
    margin-bottom: 14px !important;
    overflow: hidden;
}

.step-card > summary {
    padding: 18px 26px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #1d1d1f !important;
    list-style: none;
}

.step-card > summary::-webkit-details-marker { display: none; }

.step-card[open] > summary {
    border-bottom: 1px solid #f0f0f3 !important;
}

.step-num {
    width: 32px !important;
    height: 32px !important;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    color: white !important;
    border-radius: 50% !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.step-badge {
    border-radius: 999px !important;
    padding: 4px 12px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
}
.step-badge.required {
    background: #fef2f2 !important;
    color: #b91c1c !important;
}
.step-badge.optional {
    background: #fef3c7 !important;
    color: #92400e !important;
}
.step-badge.new {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.step-card-body {
    padding: 20px 26px 24px 26px !important;
}

/* ============================================================
   ALERTS / NOTES / RESULT CARDS — pastel
   ============================================================ */
.alert {
    border-radius: 12px !important;
    padding: 14px 18px !important;
    border: none !important;
    border-left-width: 4px !important;
    border-left-style: solid !important;
}
.alert-info { background: #eff6ff !important; color: #1e40af !important; border-left-color: #3b82f6 !important; }
.alert-warning { background: #fffbeb !important; color: #92400e !important; border-left-color: #f59e0b !important; }
.alert-danger { background: #fef2f2 !important; color: #991b1b !important; border-left-color: #ef4444 !important; }
.alert-success { background: #f0fdf4 !important; color: #166534 !important; border-left-color: #22c55e !important; }

.step-note {
    background: #f5f5f7 !important;
    border-left: 3px solid #d2d2d7 !important;
    border-radius: 10px !important;
    padding: 12px 16px !important;
    font-size: 13px !important;
    color: #424245 !important;
}

.step-inline-result {
    border-radius: 14px !important;
    border: none !important;
    border-left: 4px solid #22c55e !important;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
    padding: 16px 20px !important;
}
.step-inline-result.warning {
    border-left-color: #f59e0b !important;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%) !important;
}
.step-inline-result.error {
    border-left-color: #ef4444 !important;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%) !important;
}

.result-summary {
    background: #f5f5f7 !important;
    border-radius: 12px !important;
    padding: 16px 18px !important;
}

/* ============================================================
   TABLES — Apple-style
   ============================================================ */
.result-table-wrap, .comparison-wrap, .catalog-tab-wrapper, .library-table {
    border-radius: 14px !important;
    overflow: auto;   /* Cho phép scroll khi bảng dài hơn max-height — tránh ẩn hàng */
    border: 1px solid #f0f0f3 !important;
}

.result-table thead, .comparison-table thead, .library-table thead {
    background: #f5f5f7 !important;
}
.result-table thead th {
    background: #f5f5f7 !important;
    color: #1d1d1f !important;
    font-weight: 600 !important;
    font-size: 12.5px !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.result-table tbody td {
    border-bottom: 1px solid #f0f0f3 !important;
    padding: 12px 12px !important;
}

.result-table tr:nth-child(even) td { background: #fafafa !important; }

/* ============================================================
   HELP CARDS — Soft style
   ============================================================ */
.help-cards-wrapper {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    border: none !important;
}
.help-cards-header {
    background: transparent !important;
    color: #1d1d1f !important;
    border: none !important;
    padding: 0 0 12px 0 !important;
}
.help-cards-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #6e6e73 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.08em !important;
}
.help-card {
    background: #ffffff !important;
    border-radius: 14px !important;
    border: 1px solid rgba(0,0,0,0.04) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04) !important;
    margin-bottom: 10px !important;
    overflow: hidden;
}
.help-card > summary {
    padding: 14px 20px !important;
    background: transparent !important;
    color: #1d1d1f !important;
    font-weight: 600 !important;
    font-size: 14px !important;
}
.help-card-body {
    padding: 0 20px 18px 20px !important;
    font-size: 13.5px;
    line-height: 1.65;
    color: #424245;
}

/* ============================================================
   MODAL — Apple-style backdrop blur
   ============================================================ */
.project-modal-backdrop {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}
.project-modal-content {
    border-radius: 20px !important;
    box-shadow: 0 25px 80px rgba(0,0,0,0.25) !important;
}
.project-modal-header {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%) !important;
    padding: 18px 24px !important;
}
.project-modal-header h2 { font-size: 20px !important; font-weight: 700 !important; }
.modal-close {
    background: rgba(255,255,255,0.2) !important;
    border-radius: 8px !important;
    transition: all 0.2s !important;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    color: #86868b !important;
    font-size: 12px !important;
    padding: 30px 16px !important;
}
.footer strong { color: #6e6e73 !important; }

/* ============================================================
   TOAST — Apple notification style
   ============================================================ */
.toast {
    background: rgba(29, 29, 31, 0.92) !important;
    color: white !important;
    border-radius: 14px !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3) !important;
    padding: 14px 22px !important;
    font-weight: 500 !important;
}
.toast.warn { background: rgba(217, 119, 6, 0.94) !important; }

/* ============================================================
   TOOLTIP TIP BUTTON — smaller, subtle
   ============================================================ */
.info-tip {
    background: #f5f5f7 !important;
    color: #6e6e73 !important;
    border: none !important;
    width: 18px !important;
    height: 18px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    border-radius: 50% !important;
    margin-left: 4px;
    transition: all 0.15s;
}
.info-tip:hover { background: #2563eb !important; color: white !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px){
    body { padding: 16px 12px !important; }
    .header h1 { font-size: 32px !important; }
    .tab-nav { width: 100%; flex-wrap: wrap; }
    .tab-btn { padding: 8px 16px !important; font-size: 13px !important; }
    .step-card-body { padding: 16px !important; }
    .row { grid-template-columns: 1fr !important; }
}
