/* ==============================================
   MODULES - Feature-specific styles
   ============================================== */

/* ---- History List ---- */
.modal-container--history {
    max-width: 920px;
    width: min(96vw, 920px);
    overflow: hidden;
}

#history-tab-quotes,
#history-tab-customers {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.history-modal-title h3 {
    margin-bottom: 4px;
}

.history-modal-title p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 400;
}

.history-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr)) auto;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #fffaf4 0%, #ffffff 65%);
}

.history-current-card {
    border: 1px solid rgba(234,148,54,0.22);
    border-radius: 14px;
    padding: 10px 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.history-current-card__label,
.history-summary__label {
    display: block;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    margin-bottom: 4px;
}

.history-current-card strong {
    color: var(--brand-primary);
    font-size: var(--font-size-md);
    direction: ltr;
    display: inline-block;
}

.history-toolbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.history-summary {
    display: flex;
    gap: 10px;
    padding: 10px 18px;
    border-bottom: 1px solid #edf1f7;
    background: #f8fafc;
}

.history-summary > div {
    min-width: 120px;
    padding: 8px 10px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #edf1f7;
}

.history-summary__value {
    color: var(--text-primary);
    font-weight: 800;
    direction: ltr;
    display: inline-block;
}

.history-list {
    background: #f8fafc;
}

.history-loading {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    background: #fff;
    border-radius: 14px;
    border: 1px dashed var(--border-color);
}

.history-search {
    padding: 10px 18px;
    border-bottom: 1px solid #edf1f7;
    background: #fff;
}

.history-search input {
    width: 100%;
}

.history-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 10px;
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
    background: #fff;
    overflow: hidden;
}

.history-item:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(234,148,54,0.34);
    transform: translateY(-2px);
}

.history-item__body {
    padding: 14px 16px 10px;
    flex: 1;
}

.history-item__topline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.history-item__topline h4 {
    font-size: var(--font-size-md);
    color: var(--brand-primary);
    margin: 0;
}

.history-item__client {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.history-item__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

.history-item__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    gap: 10px;
}

.history-item__total {
    font-weight: 800;
    color: var(--text-primary);
    direction: ltr;
    font-size: 15px;
    white-space: nowrap;
}

.history-version-badge,
.history-owner-badge {
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 0.75rem;
    font-weight: 700;
}

.history-version-badge {
    background: rgba(234,148,54,0.12);
    color: var(--brand-primary);
}

.history-owner-badge {
    background: #e8f4fd;
    color: #1a6494;
}

.history-status-badge {
    border-radius: 999px;
    padding: 2px 9px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
}

.history-status-badge--draft {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #e5e7eb;
}

.history-status-badge--sent {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.history-status-badge--approved {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #bbf7d0;
}

.history-status-badge--execution {
    background: rgba(234,148,54,0.12);
    color: var(--brand-primary);
    border-color: rgba(234,148,54,0.35);
}

.history-item__actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

@media (max-width: 720px) {
    .history-toolbar {
        grid-template-columns: 1fr;
    }

    .history-toolbar__actions {
        justify-content: stretch;
    }

    .history-toolbar__actions .btn {
        flex: 1;
    }

    .history-item__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .history-item__actions {
        justify-content: stretch;
    }

    .history-item__actions .btn {
        flex: 1;
    }
}

/* ---- History tabs ---- */
.history-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    padding: 0 16px;
    gap: 4px;
    flex-shrink: 0;
}

.history-tab {
    padding: 11px 18px;
    border: none;
    border-bottom: 2.5px solid transparent;
    background: none;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.history-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.history-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* ---- Customer cards (in history modal customers tab) ---- */
.customer-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: #fff;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.customer-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(234,148,54,0.3);
}

.customer-card__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.customer-card__name {
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.customer-card__meta {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.customer-card__actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* ---- Contact exists note ---- */
.contact-exists-note {
    font-size: var(--font-size-xs);
    color: #16a34a;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f0fdf4;
    border-radius: 999px;
    border: 1px solid #bbf7d0;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
    background: #fff;
    border-radius: 14px;
    border: 1px dashed var(--border-color);
}

.empty-state__icon {
    font-size: 52px;
    margin-bottom: var(--space-md);
}

.empty-state__title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.empty-state__text {
    font-size: var(--font-size-sm);
}

/* ---- Loading Spinner ---- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--brand-violet);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: #2f2f2f;
    color: white;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    border: 1px solid rgba(255,255,255,0.12);
}

.toast--success { background: #10B981; }
.toast--error   { background: #EF4444; }
.toast--warning { background: var(--brand-primary); color: #fff; }

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to   { transform: translateX(0);      opacity: 1; }
}

/* ---- Fonts CSS (Phase 2 - offline) ---- */
@font-face {
    font-family: 'Alexandria';
    src: url('../assets/fonts/Alexandria-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: block;
}
