/* ========================================
   LINKO Management - Admin Page Styles
   ======================================== */

/* Reset body for admin layout */
.management-body {
    margin: 0;
    padding: 0;
    background: var(--neutral-50);
    min-height: 100vh;
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
}

/* ===== Auth Gate ===== */
.auth-gate {
    position: fixed;
    inset: 0;
    background: var(--navy-900);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-gate-content {
    text-align: center;
}

.auth-gate-logo {
    height: 48px;
    margin-bottom: 24px;
}

.auth-gate-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.auth-gate-text {
    color: var(--neutral-400);
    font-size: 14px;
}

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

/* ===== Admin Layout ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.admin-sidebar {
    width: 260px;
    background: var(--navy-900);
    color: var(--neutral-400);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo img {
    height: 32px;
}

.sidebar-badge {
    background: var(--primary-600);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.08em;
}

/* Override global styles from style.css */
.management-body nav {
    position: static;
    background: none;
    backdrop-filter: none;
    border-bottom: none;
    z-index: auto;
}

.management-body section {
    padding: 0;
}

.management-body footer {
    display: none;
}

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

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--neutral-400);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-link.active {
    color: white;
    background: rgba(16, 185, 129, 0.12);
    border-left-color: var(--primary-500);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

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

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

.admin-user-info > i {
    font-size: 18px;
    color: var(--primary-400);
}

.admin-name {
    display: block;
    color: var(--neutral-200);
    font-size: 13px;
    font-weight: 600;
}

.admin-email {
    display: block;
    color: var(--neutral-500);
    font-size: 11px;
}

.btn-sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--neutral-400);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ===== Mobile Header ===== */
.admin-mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--navy-900);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 99;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--neutral-300);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
}

.mobile-logo {
    height: 28px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Main Content ===== */
.admin-main {
    margin-left: 260px;
    padding: 32px;
    flex: 1;
    min-height: 100vh;
}

/* ===== Section Visibility ===== */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

/* ===== Page Header ===== */
.section-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--neutral-900);
    margin: 0;
}

.page-desc {
    color: var(--neutral-500);
    font-size: 14px;
    margin: 4px 0 0;
}

/* ===== Dashboard Cards ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon-customers { background: #dbeafe; color: #2563eb; }
.stat-icon-contracts { background: var(--primary-100); color: var(--primary-700); }
.stat-icon-quotes { background: #fef3c7; color: #d97706; }
.stat-icon-revenue { background: #ede9fe; color: #7c3aed; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--neutral-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--neutral-500);
    margin-top: 2px;
}

/* ===== Dashboard Bottom ===== */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.activity-card,
.product-summary-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    padding: 24px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--neutral-800);
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--primary-500);
    font-size: 14px;
}

/* Activity List */
.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--neutral-100);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.activity-icon.act-customer { background: #dbeafe; color: #2563eb; }
.activity-icon.act-quote { background: #fef3c7; color: #d97706; }
.activity-icon.act-contract { background: var(--primary-100); color: var(--primary-700); }
.activity-icon.act-status { background: #ede9fe; color: #7c3aed; }

.activity-text {
    flex: 1;
}

.activity-desc {
    font-size: 13px;
    color: var(--neutral-700);
    margin: 0;
}

.activity-time {
    font-size: 11px;
    color: var(--neutral-400);
    margin-top: 2px;
}

.empty-state {
    text-align: center;
    color: var(--neutral-400);
    font-size: 14px;
    padding: 32px 0;
}

/* Product Bars */
.product-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.product-bar-item:last-child {
    margin-bottom: 0;
}

.product-bar-label {
    width: 80px;
    font-size: 13px;
    font-weight: 600;
    color: var(--neutral-700);
}

.product-bar-track {
    flex: 1;
    height: 8px;
    background: var(--neutral-100);
    border-radius: 4px;
    overflow: hidden;
}

.product-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.product-bar-count {
    width: 32px;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: var(--neutral-800);
}

/* ===== Contract Summary ===== */
.contract-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.contract-summary-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.cs-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 16px;
}

.cs-active { background: var(--primary-100); color: var(--primary-700); }
.cs-maintenance { background: #dbeafe; color: #2563eb; }
.cs-expiring { background: #fef3c7; color: #d97706; }
.cs-overdue { background: #fee2e2; color: #dc2626; }

.cs-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--neutral-900);
}

.cs-label {
    display: block;
    font-size: 12px;
    color: var(--neutral-500);
    margin-top: 2px;
}

/* ===== Toolbar ===== */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-400);
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    font-size: 14px;
    color: var(--neutral-800);
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.search-input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.filter-select {
    padding: 10px 36px 10px 14px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    font-size: 14px;
    color: var(--neutral-700);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.filter-select:focus {
    border-color: var(--primary-500);
}

/* ===== Tables ===== */
.table-wrap {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    overflow: hidden;
}

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

.admin-table th {
    background: var(--neutral-50);
    color: var(--neutral-600);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--neutral-200);
    white-space: nowrap;
}

.admin-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--neutral-700);
    border-bottom: 1px solid var(--neutral-100);
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: var(--neutral-50);
}

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

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-상담중 { background: #fef3c7; color: #92400e; }
.status-견적발송 { background: #dbeafe; color: #1e40af; }
.status-계약완료 { background: var(--primary-100); color: var(--primary-800); }
.status-유지보수 { background: #ede9fe; color: #5b21b6; }

.status-draft { background: var(--neutral-100); color: var(--neutral-600); }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-accepted { background: var(--primary-100); color: var(--primary-800); }
.status-rejected { background: #fee2e2; color: #991b1b; }

.payment-pending { background: #fef3c7; color: #92400e; }
.payment-paid { background: var(--primary-100); color: var(--primary-800); }
.payment-overdue { background: #fee2e2; color: #991b1b; }

/* Table Actions */
.table-actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: 1px solid var(--neutral-200);
    border-radius: 8px;
    background: white;
    color: var(--neutral-500);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    border-color: var(--primary-500);
    color: var(--primary-600);
    background: var(--primary-50);
}

.btn-icon.btn-icon-danger:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

.btn-icon.btn-icon-send:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background: #eff6ff;
}

/* Table States */
.table-empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--neutral-400);
}

.table-empty i {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
}

.table-loading {
    text-align: center;
    padding: 32px 16px;
    color: var(--neutral-500);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border: 2px solid var(--neutral-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ===== Setup Guide ===== */
.setup-guide {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    padding: 24px;
    margin-top: 24px;
}

.guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.guide-step {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--neutral-100);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.guide-step:hover {
    border-color: var(--primary-300);
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-100);
    color: var(--primary-700);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--neutral-800);
    margin: 0 0 4px;
}

.step-content > p {
    font-size: 13px;
    color: var(--neutral-500);
    margin: 0 0 8px;
}

.step-detail {
    background: var(--neutral-50);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--neutral-700);
    line-height: 1.7;
}

.step-detail ol {
    margin: 0;
    padding-left: 20px;
}

.step-detail ol li {
    margin-bottom: 4px;
}

.step-detail code {
    background: var(--neutral-200);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary-800);
}

.step-detail a {
    color: var(--primary-600);
    text-decoration: underline;
}

.step-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--primary-600);
    font-weight: 500;
}

.template-example {
    background: var(--navy-900);
    color: var(--neutral-300);
    padding: 10px 14px;
    border-radius: 6px;
    margin: 8px 0;
    font-size: 12px;
    line-height: 1.8;
}

.template-example code {
    background: transparent;
    color: var(--primary-400);
    padding: 0;
}

.template-example p {
    margin: 0 0 4px;
    color: var(--neutral-400);
}

@media (max-width: 768px) {
    .guide-step {
        flex-direction: column;
    }
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
}

.modal-sm { max-width: 400px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 760px; }

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

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--neutral-900);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--neutral-400);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

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

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

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-200);
    flex-shrink: 0;
}

/* ===== Form Styles (extend style.css) ===== */
.management-body .form-group {
    margin-bottom: 16px;
}

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

.management-body .form-group input,
.management-body .form-group select,
.management-body .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    font-size: 14px;
    color: var(--neutral-800);
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.management-body .form-group input:focus,
.management-body .form-group select:focus,
.management-body .form-group textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background: white;
}

.management-body .form-group input[readonly] {
    background: var(--neutral-100);
    color: var(--neutral-500);
    cursor: not-allowed;
}

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

.required {
    color: #ef4444;
}

.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--neutral-800);
    margin: 20px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--neutral-100);
}

.form-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.contract-fields {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.contract-fields .form-section-title {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* ===== Quote Form ===== */
.quote-items {
    margin-bottom: 12px;
}

.quote-item-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 10px;
    margin-bottom: 8px;
}

.qi-product { flex: 2; }
.qi-qty { flex: 0.7; }
.qi-price { flex: 1.5; }
.qi-amount { flex: 1.2; }

.qi-total {
    display: block;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--neutral-800);
}

.qi-remove {
    margin-bottom: 16px;
}

.quote-item-row .form-group {
    margin-bottom: 0;
}

.quote-totals {
    background: var(--neutral-50);
    border: 1px solid var(--neutral-200);
    border-radius: 12px;
    padding: 16px 20px;
    margin: 16px 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
    color: var(--neutral-600);
}

.total-final {
    border-top: 2px solid var(--neutral-300);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--neutral-900);
}

.quote-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: 10px;
    padding: 14px 16px;
    margin-top: 16px;
}

.quote-notice i {
    color: var(--primary-600);
    margin-top: 2px;
    flex-shrink: 0;
}

.quote-notice p {
    font-size: 13px;
    color: var(--primary-800);
    margin: 0;
    line-height: 1.5;
}

/* ===== Button Variants ===== */
.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.toast-success {
    background: var(--primary-600);
    color: white;
}

.toast.toast-error {
    background: #ef4444;
    color: white;
}

.toast.toast-info {
    background: #3b82f6;
    color: white;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

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

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

/* ===== Maintenance Badge ===== */
.maintenance-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.maintenance-active.active {
    background: var(--primary-100);
    color: var(--primary-800);
}

.maintenance-active.inactive {
    background: var(--neutral-100);
    color: var(--neutral-500);
}

/* ===== Sidebar AI Badge ===== */
.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 16px;
}

.sidebar-badge-ai {
    margin-left: auto;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* ===== AI Chat Section ===== */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 96px);
    max-height: 900px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* Chat Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--neutral-200);
    background: linear-gradient(135deg, #f8fafc, #f0fdf4);
    flex-shrink: 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.ai-chat-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--neutral-900);
    margin: 0;
}

.ai-chat-subtitle {
    font-size: 12px;
    color: var(--neutral-500);
}

.ai-chat-header-actions {
    display: flex;
    gap: 8px;
}

/* Chat Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Message Bubble */
.ai-msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: msgFadeIn 0.3s ease;
}

.ai-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-assistant {
    align-self: flex-start;
}

.ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.ai-msg-assistant .ai-msg-avatar {
    background: var(--primary-100);
    color: var(--primary-700);
}

.ai-msg-user .ai-msg-avatar {
    background: var(--navy-900);
    color: white;
}

.ai-msg-bubble {
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
}

.ai-msg-bubble p {
    margin: 0 0 8px;
}

.ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.ai-msg-assistant .ai-msg-bubble {
    background: var(--neutral-100);
    color: var(--neutral-800);
    border-bottom-left-radius: 4px;
}

.ai-msg-user .ai-msg-bubble {
    background: var(--primary-600);
    color: white;
    border-bottom-right-radius: 4px;
}

/* Markdown inside bubbles */
.ai-msg-bubble strong {
    font-weight: 700;
}

.ai-msg-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.ai-msg-user .ai-msg-bubble code {
    background: rgba(255, 255, 255, 0.15);
}

.ai-msg-bubble pre {
    background: var(--navy-900);
    color: var(--neutral-300);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    overflow-x: auto;
    margin: 8px 0;
}

.ai-msg-bubble pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.ai-msg-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

.ai-msg-bubble li {
    margin-bottom: 4px;
}

/* Tool Execution Indicator */
.ai-msg-tool {
    align-self: flex-start;
    max-width: 80%;
}

.ai-tool-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f5f3ff;
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    font-size: 13px;
    color: #6366f1;
}

.ai-tool-card i {
    font-size: 14px;
}

.ai-tool-card .tool-name {
    font-weight: 600;
}

/* Quick Actions */
.ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.ai-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--neutral-700);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.ai-quick-btn:hover {
    border-color: var(--primary-400);
    color: var(--primary-700);
    background: var(--primary-50);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.12);
}

.ai-quick-btn i {
    font-size: 12px;
    color: var(--primary-500);
}

/* Typing Indicator */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px 16px;
    flex-shrink: 0;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-400);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.ai-typing-text {
    font-size: 12px;
    color: var(--neutral-400);
}

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

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

/* Chat Input Area */
.ai-chat-input-area {
    padding: 16px 24px 12px;
    border-top: 1px solid var(--neutral-200);
    background: var(--neutral-50);
    flex-shrink: 0;
}

.ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: 16px;
    padding: 8px 8px 8px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-input-wrap:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.ai-chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--neutral-800);
    background: transparent;
    line-height: 1.5;
    max-height: 120px;
    padding: 4px 0;
}

.ai-chat-input::placeholder {
    color: var(--neutral-400);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--primary-600);
    color: white;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    background: var(--primary-700);
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: var(--neutral-300);
    cursor: not-allowed;
    transform: none;
}

.ai-chat-footer-info {
    text-align: center;
    padding-top: 8px;
    font-size: 11px;
    color: var(--neutral-400);
}

/* Error message in chat */
.ai-msg-error .ai-msg-bubble {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .contract-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-mobile-header {
        display: flex;
    }

    .admin-main {
        margin-left: 0;
        padding: 72px 16px 24px;
    }

    .dashboard-bottom {
        grid-template-columns: 1fr;
    }

    /* Table horizontal scroll */
    .table-wrap {
        overflow-x: auto;
    }

    .admin-table {
        min-width: 700px;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .contract-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-toolbar {
        flex-direction: column;
    }

    .search-wrap {
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .management-body .form-row {
        grid-template-columns: 1fr;
    }

    .quote-item-row {
        flex-wrap: wrap;
    }

    .qi-product { flex: 1 1 100%; }
    .qi-qty { flex: 1; }
    .qi-price { flex: 1; }
    .qi-amount { flex: 1; }

    .modal-lg {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .contract-summary-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 22px;
    }

    .page-title {
        font-size: 20px;
    }

    .ai-chat-container {
        border-radius: 0;
        border: none;
        height: calc(100vh - 80px);
    }

    .ai-chat-header {
        padding: 12px 16px;
    }

    .ai-chat-messages {
        padding: 16px;
    }

    .ai-msg {
        max-width: 92%;
    }

    .ai-chat-input-area {
        padding: 12px 16px 8px;
    }

    .ai-quick-btn {
        font-size: 12px;
        padding: 6px 10px;
    }
}
