/* ============================================
   MADINAT AL SAADA - AI QUOTATION SYSTEM
   Clean Professional UI
   ============================================ */

:root {
    --primary: #1a5f7a;
    --primary-dark: #134b61;
    --primary-light: #2d7d9a;
    --secondary: #c9a227;
    --secondary-light: #d4b54a;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --dark: #212529;
    --gray-900: #343a40;
    --gray-700: #495057;
    --gray-600: #6c757d;
    --gray-400: #ced4da;
    --gray-300: #dee2e6;
    --gray-200: #e9ecef;
    --gray-100: #f8f9fa;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dark);
    background: var(--gray-100);
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    text-align: center;
}

.login-logo {
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 120px;
    height: auto;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 30px;
}

.login-form {
    text-align: left;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
}

/* ============================================
   FORMS
   ============================================ */

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--dark);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.form-group input:disabled,
.form-group select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

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

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

.error-message {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}

.error-message.show {
    display: block;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-gold {
    background: var(--secondary);
    color: var(--white);
}

.btn-gold:hover {
    background: var(--secondary-light);
}

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

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    text-align: center;
}

.sidebar-header img {
    max-width: 60px;
    margin-bottom: 8px;
}

.sidebar-header h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-item.active {
    background: rgba(26, 95, 122, 0.08);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 500;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--gray-600);
    text-transform: capitalize;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    background: var(--gray-100);
}

.page-header {
    background: var(--white);
    padding: 20px 30px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark);
}

.page-subtitle {
    font-size: 13px;
    color: var(--gray-600);
    margin-top: 2px;
}

.page-content {
    padding: 24px 30px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dark);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-100);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ============================================
   STATS CARDS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.stat-card.gold {
    background: linear-gradient(135deg, var(--secondary) 0%, #b8922a 100%);
    color: var(--white);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
}

/* ============================================
   TABLES
   ============================================ */

.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-100);
}

td {
    font-size: 14px;
    color: var(--dark);
}

tr:hover td {
    background: var(--gray-100);
}

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

/* ============================================
   BADGES
   ============================================ */

.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #9a7b00;
}

.badge-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.badge-primary {
    background: rgba(26, 95, 122, 0.1);
    color: var(--primary);
}

.badge-gray {
    background: var(--gray-200);
    color: var(--gray-700);
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-lg {
    max-width: 900px;
}

.modal-xl {
    max-width: 1200px;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--dark);
}

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

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   WIZARD / STEPS
   ============================================ */

.wizard-progress {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

.wizard-step {
    display: flex;
    align-items: center;
    color: var(--gray-600);
    font-size: 13px;
}

.wizard-step:not(:last-child)::after {
    content: '';
    width: 60px;
    height: 2px;
    background: var(--gray-300);
    margin: 0 12px;
}

.wizard-step.active .step-number,
.wizard-step.completed .step-number {
    background: var(--primary);
    color: var(--white);
}

.wizard-step.active,
.wizard-step.completed {
    color: var(--primary);
}

.wizard-step.completed:not(:last-child)::after {
    background: var(--primary);
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-300);
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    margin-right: 8px;
}

.wizard-content {
    min-height: 300px;
}

.wizard-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   FILE UPLOAD
   ============================================ */

.file-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-100);
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: rgba(26, 95, 122, 0.05);
}

.file-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(26, 95, 122, 0.1);
}

.file-upload-icon {
    font-size: 40px;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.file-upload-text {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.file-upload-hint {
    font-size: 12px;
    color: var(--gray-500);
}

.file-list {
    margin-top: 16px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.file-item-name {
    font-size: 13px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
}

/* ============================================
   AI ANALYSIS
   ============================================ */

.ai-analysis-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.ai-analysis-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.ai-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.ai-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.ai-subtitle {
    font-size: 12px;
    color: var(--gray-600);
}

.ai-status {
    padding: 12px;
    background: var(--white);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--gray-700);
}

.ai-status.analyzing {
    color: var(--primary);
}

.ai-status.complete {
    color: var(--success);
}

.ai-status.error {
    color: var(--danger);
}

/* ============================================
   QUANTITY BREAKDOWN
   ============================================ */

.breakdown-section {
    margin-bottom: 24px;
}

.breakdown-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    padding: 10px 16px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.breakdown-items {
    display: grid;
    gap: 8px;
}

.breakdown-item {
    display: grid;
    grid-template-columns: 1fr 100px 80px 100px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.breakdown-item-desc {
    color: var(--dark);
}

.breakdown-item-qty {
    color: var(--primary);
    font-weight: 500;
    text-align: center;
}

.breakdown-item-unit {
    color: var(--gray-600);
    text-align: center;
}

.breakdown-item-rate {
    text-align: right;
}

.breakdown-item-rate input {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    text-align: right;
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    font-size: 14px;
    color: var(--gray-600);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: var(--transition);
}

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

.tab-content {
    display: none;
}

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

/* ============================================
   DATABASE MANAGEMENT
   ============================================ */

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.category-tab {
    padding: 8px 16px;
    font-size: 13px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.category-tab:hover {
    background: var(--gray-200);
}

.category-tab.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.db-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 100px 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.db-item-row:hover {
    background: var(--gray-100);
}

.db-item-row input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
}

/* ============================================
   QUOTATION PREVIEW
   ============================================ */

.quotation-preview {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 900px;
    margin: 0 auto;
}

.quotation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary);
}

.quotation-logo img {
    max-width: 100px;
}

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

.quotation-company h1 {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 4px;
}

.quotation-company p {
    font-size: 12px;
    color: var(--gray-600);
}

.quotation-title {
    text-align: center;
    margin-bottom: 30px;
}

.quotation-title h2 {
    font-size: 24px;
    color: var(--dark);
    margin-bottom: 4px;
}

.quotation-ref {
    font-size: 13px;
    color: var(--gray-600);
}

.quotation-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.quotation-section h3 {
    font-size: 13px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.quotation-section p {
    font-size: 14px;
    color: var(--dark);
    margin-bottom: 4px;
}

.quotation-table {
    margin-bottom: 30px;
}

.quotation-table th {
    background: var(--primary);
    color: var(--white);
    font-size: 12px;
}

.quotation-table td {
    font-size: 13px;
}

.quotation-table .item-desc {
    font-weight: 500;
}

.quotation-table .sub-item {
    padding-left: 30px;
    color: var(--gray-700);
    font-size: 12px;
}

.quotation-summary {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 30px;
}

.summary-table {
    width: 300px;
}

.summary-table td {
    padding: 8px 12px;
    border: none;
}

.summary-table .total-row {
    font-weight: 600;
    font-size: 16px;
    background: var(--gray-100);
}

.quotation-terms {
    margin-bottom: 30px;
}

.quotation-terms h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--dark);
}

.quotation-terms ol {
    padding-left: 20px;
    font-size: 12px;
    color: var(--gray-700);
}

.quotation-terms li {
    margin-bottom: 6px;
}

.quotation-signature {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 60px;
}

.signature-block h4 {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 40px;
}

.signature-line {
    border-top: 1px solid var(--gray-400);
    padding-top: 8px;
    font-size: 12px;
    color: var(--gray-600);
}

/* ============================================
   LOADING
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-text {
    margin-top: 16px;
    font-size: 14px;
    color: var(--gray-700);
}

/* ============================================
   UTILITIES
   ============================================ */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--gray-600); }
.text-small { font-size: 12px; }
.font-bold { font-weight: 600; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden { display: none !important; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }
    .breakdown-item {
        grid-template-columns: 1fr 1fr;
    }
    .quotation-details {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .page-header,
    .wizard-actions,
    .btn {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
    .quotation-preview {
        border: none;
        box-shadow: none;
        padding: 0;
    }
}
