/* ═══════════════════════════════════════════════════════════════
   Form Styles — Inputs, Tabs, Sections, Upload Areas
   ═══════════════════════════════════════════════════════════════ */

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    animation: fadeIn 0.3s ease-out;
}

.page-title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 22px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title-icon {
    font-size: 26px;
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Mode Toggle Bar ─────────────────────────────────────────── */
.mode-toggle-bar {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 4px;
    gap: 4px;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: var(--space-md);
    z-index: var(--z-sticky);
    margin-bottom: var(--space-lg);
}

.mode-toggle-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-toggle-btn.active {
    background: var(--sidebar-bg);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
}

.mode-toggle-btn:not(.active) {
    background: var(--content-bg);
    color: var(--text-secondary);
}

.mode-toggle-btn:not(.active):hover {
    background: var(--border-color);
}

/* ── Form Layout Grid ────────────────────────────────────────── */
.form-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-lg);
    align-items: start;
}

@media (max-width: 1200px) {
    .form-layout {
        grid-template-columns: 1fr;
    }
}

/* ── Tab Navigation ──────────────────────────────────────────── */
.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border-light);
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    scroll-behavior: smooth;
    margin-bottom: var(--space-lg);
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 10px 18px;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    user-select: none;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--text-primary);
}

.tab-panel {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
    display: block;
}

/* ── Form Section ────────────────────────────────────────────── */
.form-section {
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.form-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-section-title.blue { color: var(--accent-quotation); }
.form-section-title.purple { color: var(--accent-billing); }
.form-section-title.amber { color: var(--accent-receipt); }
.form-section-title.green { color: var(--primary); }
.form-section-title.slate { color: var(--text-secondary); }

/* ── Input Fields ────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-label-muted {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.form-input::placeholder {
    color: var(--text-placeholder);
}

.form-input-sm {
    padding: 8px 10px;
    font-size: 12px;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8.825L1.175 4 2.238 2.938 6 6.7l3.763-3.762L10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* ── Grid System for Forms ───────────────────────────────────── */
.form-grid {
    display: grid;
    gap: var(--space-md);
}

.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 640px) {
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 641px) and (max-width: 1023px) {
    .form-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Toggle Switch ───────────────────────────────────────────── */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.toggle-label {
    display: flex;
    flex-direction: column;
}

.toggle-label-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-primary);
}

.toggle-label-desc {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

/* ── Upload Area ─────────────────────────────────────────────── */
.upload-area {
    position: relative;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 90px;
}

.upload-area:hover {
    border-color: var(--text-primary);
    background: var(--content-bg);
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.upload-icon {
    font-size: 22px;
    margin-bottom: 4px;
}

.upload-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
}

.upload-hint {
    font-size: 8px;
    color: var(--text-placeholder);
    margin-top: 2px;
}

.upload-preview {
    position: absolute;
    inset: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    z-index: 5;
}

.upload-preview.has-image {
    display: flex;
}

.upload-preview img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.upload-clear-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
    transition: background var(--transition-fast);
    border: none;
    cursor: pointer;
}

.upload-clear-btn:hover {
    background: #dc2626;
}

/* ── Item Row Card ───────────────────────────────────────────── */
.item-card {
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: border-color var(--transition-fast);
    animation: fadeIn 0.2s ease-out;
}

.item-card:hover {
    border-color: var(--text-muted);
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    margin-bottom: var(--space-sm);
}

.item-card-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-secondary);
}

.item-card-total {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-align: right;
    padding-top: var(--space-xs);
}

.item-card-total strong {
    color: var(--text-primary);
    font-weight: 800;
}

/* ── Summary Sidebar Widget ──────────────────────────────────── */
.summary-widget {
    background: var(--sidebar-bg);
    color: #fff;
    padding: var(--space-lg);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(30, 41, 59, 0.8);
    box-shadow: var(--card-shadow-lg);
    position: sticky;
    top: 80px;
}

.summary-widget-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
}

.summary-row-label {
    color: var(--sidebar-text);
}

.summary-row-value {
    font-weight: 700;
    color: #fff;
}

.summary-row-value.highlight {
    color: var(--primary);
    font-weight: 800;
    font-size: 14px;
}

.summary-row.total {
    border-top: 1px solid var(--sidebar-border);
    padding-top: var(--space-sm);
    margin-top: var(--space-sm);
}

/* ── Bank Card ───────────────────────────────────────────────── */
.bank-card {
    padding: 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast);
}

.bank-card:hover {
    border-color: var(--text-placeholder);
}

.bank-card-label {
    font-size: 10px;
    font-weight: 800;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 10px;
}

/* ── Signature Section ───────────────────────────────────────── */
.sign-card {
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.sign-card-label {
    font-weight: 800;
    font-size: 12px;
    color: var(--text-secondary);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-sm);
}

/* ── Mobile Bottom Bar ───────────────────────────────────────── */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--sidebar-bg);
    color: #fff;
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    z-index: var(--z-sticky);
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 1200px) {
    .summary-widget-desktop {
        display: none;
    }

    .mobile-bottom-bar {
        display: flex;
    }
}

.mobile-bar-amount {
    display: flex;
    flex-direction: column;
}

.mobile-bar-label {
    font-size: 9px;
    color: var(--sidebar-text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mobile-bar-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    margin-top: 2px;
}

.mobile-bar-actions {
    display: flex;
    gap: 4px;
}

/* ── Action Buttons Row ──────────────────────────────────────── */
.action-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-sm);
    padding-top: var(--space-sm);
}

@media (max-width: 640px) {
    .action-row {
        grid-template-columns: 1fr;
    }

    .mode-toggle-btn {
        padding: 8px 12px !important;
        font-size: 11px !important;
    }

    .tab-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
}

/* ── Quick Date Buttons ──────────────────────────────────────── */
.quick-date-btn {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-quotation);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition-fast);
}

.quick-date-btn:hover {
    color: #2563eb;
}

/* ── Address Block ───────────────────────────────────────────── */
.address-block {
    background: var(--card-bg);
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.address-block-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-sm);
}

/* ── Calculation Summary (Tab internal) ──────────────────────── */
.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
}

.calc-label {
    color: var(--text-muted);
}

.calc-value {
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: right;
    font-weight: 800;
    color: var(--text-primary);
    min-width: 120px;
}

.calc-value.total {
    background: var(--sidebar-bg);
    border-color: var(--sidebar-bg);
    color: #fff;
}
