/* ==========================================================================
   Aluminium Atelier - Quotation System Styles
   Inspired by precision aluminium extrusion profiles and warm Portuguese
   workshop aesthetics.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
    --bg: #F5F1EC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1B2028;
    --bg-hover: #EDE9E3;
    --bg-input: #FAFAF8;
    --text: #1B2028;
    --text-muted: #7A7D82;
    --text-on-dark: #F5F1EC;
    --text-on-dark-muted: #9AA5B4;
    --accent: #C87533;
    --accent-hover: #A85E28;
    --accent-light: rgba(200, 117, 51, 0.08);
    --aluminium: #9AA5B4;
    --aluminium-light: #D1D6DE;
    --border: #E5E0DA;
    --border-focus: #C87533;
    --success: #3D8B5E;
    --success-bg: rgba(61, 139, 94, 0.08);
    --warning: #D4A843;
    --warning-bg: rgba(212, 168, 67, 0.08);
    --danger: #C75050;
    --danger-bg: rgba(199, 80, 80, 0.08);
    --draft: #6B7280;
    --draft-bg: rgba(107, 114, 128, 0.08);
    --sent: #3B82F6;
    --sent-bg: rgba(59, 130, 246, 0.08);
    --accepted: #3D8B5E;
    --accepted-bg: rgba(61, 139, 94, 0.08);
    --rejected: #C75050;
    --rejected-bg: rgba(199, 80, 80, 0.08);
    --expired: #D4A843;
    --expired-bg: rgba(212, 168, 67, 0.08);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(27, 32, 40, 0.05);
    --shadow: 0 1px 3px rgba(27, 32, 40, 0.08), 0 1px 2px rgba(27, 32, 40, 0.04);
    --shadow-lg: 0 4px 12px rgba(27, 32, 40, 0.1), 0 2px 4px rgba(27, 32, 40, 0.06);
    --sidebar-width: 260px;
    --header-height: 64px;
    --transition: 150ms ease;
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'DM Serif Display', Georgia, serif;
    font-weight: 400;
    line-height: 1.3;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.view-fade-in {
    animation: fadeIn 0.2s ease forwards;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 24px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.4rem;
    color: var(--accent);
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.sidebar-brand p {
    font-size: 0.78rem;
    color: var(--text-on-dark-muted);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-on-dark-muted);
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-on-dark);
}

.nav-item.active {
    background: rgba(200, 117, 51, 0.1);
    color: var(--text-on-dark);
    border-left-color: var(--accent);
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer span {
    font-size: 0.75rem;
    color: var(--text-on-dark-muted);
}

/* --------------------------------------------------------------------------
   Main Content Area
   -------------------------------------------------------------------------- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 50;
}

.top-bar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    transition: color var(--transition);
    cursor: pointer;
}

.breadcrumb a:hover {
    color: var(--accent);
}

.breadcrumb .separator {
    color: var(--aluminium-light);
}

.breadcrumb .current {
    color: var(--text);
    font-weight: 500;
}

.view-content {
    flex: 1;
    padding: 28px 32px;
}

/* --------------------------------------------------------------------------
   Loading State
   -------------------------------------------------------------------------- */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--aluminium-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
}

.stat-card .stat-value {
    font-family: 'DM Serif Display', serif;
    font-size: 1.75rem;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.table-header h3 {
    font-size: 1rem;
    font-weight: 400;
}

.data-table {
    width: 100%;
}

.data-table thead th {
    background: #F8F6F3;
    padding: 10px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--transition);
    cursor: pointer;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr.clickable-row:hover {
    background: var(--accent-light);
}

.data-table .col-number,
.data-table .col-date,
.data-table .col-count,
.data-table .col-price {
    text-align: right;
    white-space: nowrap;
}

.data-table .col-number th,
.data-table .col-date th,
.data-table .col-count th,
.data-table .col-price th {
    text-align: right;
}

.data-table .empty-row td {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-style: italic;
}

.text-right {
    text-align: right;
}

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

.text-small {
    font-size: 0.82rem;
}

/* --------------------------------------------------------------------------
   Status Badges
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.badge-draft {
    color: var(--draft);
    background: var(--draft-bg);
}

.badge-sent {
    color: var(--sent);
    background: var(--sent-bg);
}

.badge-accepted {
    color: var(--accepted);
    background: var(--accepted-bg);
}

.badge-rejected {
    color: var(--rejected);
    background: var(--rejected-bg);
}

.badge-expired {
    color: var(--expired);
    background: var(--expired-bg);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.88rem;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
    white-space: nowrap;
    cursor: pointer;
    border: none;
    line-height: 1.4;
}

.btn:active {
    transform: translateY(0.5px);
}

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--aluminium-light);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--aluminium);
    color: #FFFFFF;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
}

.btn-danger:hover {
    background: #B04040;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.82rem;
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

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

.form-input:focus,
.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(200, 117, 51, 0.12);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-bar .form-select {
    width: auto;
    min-width: 160px;
    padding: 7px 12px;
    font-size: 0.85rem;
}

/* --------------------------------------------------------------------------
   Page Header
   -------------------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 400;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
    cursor: pointer;
}

.back-link:hover {
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   Quote Detail
   -------------------------------------------------------------------------- */
.quote-header-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
}

.quote-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.quote-header-info h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.quote-header-meta {
    display: flex;
    gap: 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.quote-header-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.quote-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quote-summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    min-width: 260px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
}

.summary-row.total {
    border-top: 2px solid var(--border);
    margin-top: 8px;
    padding-top: 12px;
}

.summary-row.total .summary-value {
    font-family: 'DM Serif Display', serif;
    font-size: 1.2rem;
    color: var(--text);
}

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

.summary-value {
    font-weight: 600;
}

/* Line item config description */
.item-description {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

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

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

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.15s ease forwards;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(27, 32, 40, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.2s ease forwards;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 400;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    color: var(--text-muted);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    border: none;
    background: none;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* --------------------------------------------------------------------------
   Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--aluminium);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem;
    min-width: 280px;
    max-width: 420px;
    animation: slideInRight 0.25s ease forwards;
}

.toast.toast-success {
    border-left-color: var(--success);
}

.toast.toast-error {
    border-left-color: var(--danger);
}

.toast.toast-warning {
    border-left-color: var(--warning);
}

.toast.toast-info {
    border-left-color: var(--sent);
}

.toast-close {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 2px;
    cursor: pointer;
    background: none;
    border: none;
    transition: color var(--transition);
}

.toast-close:hover {
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Dropdown Menu
   -------------------------------------------------------------------------- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 60;
    padding: 4px 0;
    display: none;
}

.dropdown-menu.open {
    display: block;
    animation: fadeIn 0.1s ease forwards;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--text);
    background: none;
    border: none;
    cursor: pointer;
    transition: background var(--transition);
    text-align: left;
}

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

.dropdown-item .badge {
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Responsive (minimal - desktop-first app)
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-content {
        margin-left: 0;
    }
    .stat-cards {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .quote-header-top {
        flex-direction: column;
        gap: 12px;
    }
    .quote-actions {
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   Login Overlay
   -------------------------------------------------------------------------- */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    animation: fadeInUp 0.25s ease forwards;
}

.login-brand {
    font-family: 'DM Serif Display', serif;
    font-size: 1.6rem;
    color: var(--accent);
    letter-spacing: 0.06em;
    text-align: center;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}

.login-btn {
    width: 100%;
    padding: 10px;
    font-size: 0.92rem;
    margin-top: 4px;
}

.login-error {
    font-size: 0.82rem;
    color: var(--danger);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--danger-bg);
    border-radius: var(--radius-sm);
}

.sidebar-logout {
    display: block;
    width: 100%;
    padding: 8px 0;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-on-dark-muted);
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    transition: color var(--transition);
}

.sidebar-logout:hover {
    color: var(--danger);
}
