﻿/* ============================================================
   SignBridge — Apple-style Design System
   Brand: Deep Navy #1e3a5f
   See: /DESIGN.md for full token reference
   ============================================================ */

:root {
    /* Brand */
    --brand:        #1e3a5f;
    --brand-hover:  #163050;
    --brand-soft:   #f0f4fa;
    --brand-ring:   rgba(30, 58, 95, 0.12);

    /* Surface */
    --bg-primary:   #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary:  #f0f1f4;

    /* Text */
    --text-primary:   #1d1d1f;
    --text-secondary: #6b7280;
    --text-tertiary:  #9ca3af;
    --text-on-brand:  #ffffff;

    /* Border */
    --border:        #e5e7eb;
    --border-strong: #d1d5db;

    /* Status */
    --success:      #10b981;
    --success-soft: #ecfdf5;
    --danger:       #ef4444;
    --danger-soft:  #fef2f2;
    --warning:      #f59e0b;
    --warning-soft: #fffbeb;
    --info:         #3b82f6;
    --info-soft:    #eff6ff;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    /* Shadow */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.10);

    /* Motion */
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --duration: 0.2s;
}

/* ============================================================
   Reset & base
   ============================================================ */

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

html, body {
    font-family: 'Pretendard Variable', Pretendard,
                 -apple-system, BlinkMacSystemFont, 'SF Pro Display',
                 'Apple SD Gothic Neo', 'Malgun Gothic',
                 system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--text-primary);
    user-select: none;
    letter-spacing: -0.01em;
}

/* a 태그 기본 — color inherit (부모 색 상속).
   brand 색 링크는 명시적으로 .text-brand utility 사용. */
a {
    color: inherit;
    text-decoration: none;
    transition: color var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

a:hover {
    opacity: 0.8;
}

/* button 태그 기본 reset — 브라우저 default 제거, .btn class로 명시적 스타일링 */
button {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: inherit;
}

button:focus {
    outline: none;
}

button:disabled {
    cursor: not-allowed;
}

/* 모달 닫기 버튼 등 class 없는 button에도 hover 피드백 */
button:not([class]):hover,
button[class=""]:hover {
    opacity: 0.7;
}

/* Content 영역 명시적 링크 — .link class 사용 권장 */
.link,
a.text-brand {
    color: var(--brand);
}

.link:hover,
a.text-brand:hover {
    color: var(--brand-hover);
    opacity: 1;
    text-decoration: underline;
}

/* ============================================================
   Sidebar nav (변경: gradient 제거 → 흰 배경)
   _Layout.cshtml의 Tailwind 그라디언트 클래스는 여기서 override
   ============================================================ */

#sidebar {
    background: var(--bg-primary) !important;
    background-image: none !important;
    border-right: 1px solid var(--border);
    color: var(--text-primary) !important;
}

#sidebar h1 {
    color: var(--text-primary) !important;
}

#sidebar .text-purple-200,
#sidebar [class*="text-purple"] {
    color: var(--text-secondary) !important;
}

#sidebar .border-purple-600 {
    border-color: var(--border) !important;
}

/* sidebar 로고 박스: 흰 배경 → brand 배경 */
#sidebar .bg-white {
    background: var(--brand) !important;
}

#sidebar .text-purple-600 {
    color: var(--text-on-brand) !important;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    transition: background-color var(--duration) var(--ease),
                color var(--duration) var(--ease);
    color: var(--text-secondary);
    text-decoration: none;
    gap: 12px;
    font-weight: 500;
    font-size: 14px;
}

    .nav-item:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }

    .nav-item.active {
        background: var(--brand-soft);
        color: var(--brand);
        font-weight: 600;
    }

    .nav-item i {
        font-size: 16px;
        width: 20px;
        text-align: center;
    }

/* ============================================================
   Stat / dashboard cards
   ============================================================ */

/* .stat-card — Dashboard 위젯 카드.
   background/border는 사용처에서 utility class로 결정 (색상 차별화) */
.stat-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
    position: relative;
    overflow: hidden;
}

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

    .stat-card.dashboard-widget:hover .widget-hint {
        opacity: 1 !important;
    }

    .stat-card.dashboard-widget:hover .widget-icon {
        transform: scale(1.04);
    }

/* ============================================================
   Modal
   ============================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.2s var(--ease);
}

    .modal.show {
        display: flex;
        align-items: center;
        justify-content: center;
    }

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s var(--ease);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.estimate-modal-content {
    max-width: 95%;
    width: 95%;
    padding: 20px;
    max-height: 95vh;
}

@media (max-width: 640px) {
    .estimate-modal-content {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding: 16px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .estimate-modal-content {
        max-width: 90%;
        width: 90%;
        padding: 24px;
    }
}

@media (min-width: 1025px) {
    .estimate-modal-content {
        max-width: 1040px;
        width: 90%;
        padding: 32px;
    }
}

@media (min-width: 1440px) {
    .estimate-modal-content {
        max-width: 1200px;
        padding: 36px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ============================================================
   Data table
   ============================================================ */

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

    .data-table thead {
        background: var(--bg-secondary);
        color: var(--text-secondary);
    }

    .data-table th {
        padding: 14px 16px;
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        padding: 16px;
        border-bottom: 1px solid var(--border);
        color: var(--text-primary);
        font-size: 14px;
        text-align: left;
        vertical-align: middle;
    }

    /* 숫자/금액 컬럼: 오른쪽 정렬 권장 (정석 UX)
       사용법: <td class="data-table-number">...</td> */
    .data-table td.data-table-number {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .data-table th.data-table-number {
        text-align: right;
    }

    .data-table tbody tr {
        transition: background-color var(--duration) var(--ease);
    }

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

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

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease),
                color var(--duration) var(--ease),
                border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease);
    min-height: 40px;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-ring);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 16px;
    min-height: 48px;
}

/* Icon-only 버튼 — 정사각형, Apple 스타일
   사용법: <button class="btn btn-sm btn-icon btn-secondary" title="...">
               <i class="fas fa-..."></i>
           </button> */
.btn-icon {
    padding: 0;
    min-width: 40px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

.btn-icon.btn-sm {
    min-width: 32px;
}

.btn-icon.btn-lg {
    min-width: 48px;
}

.btn-icon i {
    font-size: 14px;
    margin: 0;
}

.btn-primary {
    background: var(--brand);
    color: var(--text-on-brand);
    border-color: var(--brand);
}

    .btn-primary:hover {
        background: var(--brand-hover);
        border-color: var(--brand-hover);
    }

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

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

.btn-success {
    background: var(--success);
    color: var(--text-on-brand);
    border-color: var(--success);
}

    .btn-success:hover {
        background: #059669;
        border-color: #059669;
    }

.btn-danger {
    background: var(--danger);
    color: var(--text-on-brand);
    border-color: var(--danger);
}

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

.btn-warning {
    background: var(--warning);
    color: var(--text-on-brand);
    border-color: var(--warning);
}

    .btn-warning:hover {
        background: #d97706;
        border-color: #d97706;
    }

.btn-ghost {
    background: transparent;
    color: var(--brand);
    border-color: transparent;
}

    .btn-ghost:hover {
        background: var(--brand-soft);
    }

/* ============================================================
   Forms
   ============================================================ */

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease);
    min-height: 40px;
}

    .form-input:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        border-color: var(--brand);
        box-shadow: 0 0 0 3px var(--brand-ring);
    }

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

    .form-input[readonly] {
        background: var(--bg-secondary);
        color: var(--text-secondary);
    }

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='%236b7280' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* 컴팩트 폼 입력 (테이블/리스트 행 안에서 사용) */
.form-input.form-input-sm {
    padding: 6px 10px;
    font-size: 13px;
    height: 34px;
}

select.form-input.form-input-sm {
    padding-right: 28px;
    background-position: right 8px center;
}

/* ============================================================
   Sidebar responsive
   ============================================================ */

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

        #sidebar.show,
        #sidebar:not(.-translate-x-full) {
            transform: translateX(0);
        }
}

/* ============================================================
   Loading
   ============================================================ */

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

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

/* ============================================================
   Toast (gradient 제거, 미묘한 좌측 border만 유지)
   ============================================================ */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 460px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left-width: 3px;
    pointer-events: auto;
    animation: slideInRight 0.2s var(--ease);
}

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

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

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

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

.toast i {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast.info i { color: var(--info); }

.toast span {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

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

/* ============================================================
   Confirm dialog (gradient 제거)
   ============================================================ */

.confirm-dialog-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s var(--ease);
}

.confirm-dialog {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s var(--ease);
    overflow: hidden;
    border: 1px solid var(--border);
}

.confirm-dialog-header {
    background: var(--bg-primary);
    padding: 20px 24px 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.confirm-dialog-header i {
    font-size: 20px;
    color: var(--brand);
}

.confirm-dialog-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.confirm-dialog-body {
    padding: 20px 24px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}

.confirm-dialog-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--bg-secondary);
}

.confirm-btn {
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease),
                border-color var(--duration) var(--ease);
    border: 1px solid transparent;
    min-width: 72px;
    font-family: inherit;
}

.confirm-btn-cancel {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

    .confirm-btn-cancel:hover {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }

.confirm-btn-ok {
    background: var(--brand);
    color: var(--text-on-brand);
    border-color: var(--brand);
}

    .confirm-btn-ok:hover {
        background: var(--brand-hover);
        border-color: var(--brand-hover);
    }

/* ============================================================
   Scrollbar (subtle)
   ============================================================ */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid var(--bg-secondary);
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-tertiary);
    }

/* ============================================================
   Empty state (new — High issue #3 부분 해결)
   사용법: <div class="empty-state">...</div>
   ============================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.empty-state-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    max-width: 360px;
}

/* ============================================================
   Focus visible for accessibility
   ============================================================ */

*:focus-visible {
    outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ============================================================
   Status badge (pill) — 견적 상태 표시용
   사용법: <span class="status-badge status-draft">초안</span>
   ============================================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
}

.status-draft     { background: var(--bg-tertiary); color: var(--text-secondary); border-color: var(--border-strong); }
.status-edit      { background: var(--info-soft); color: var(--info); border-color: rgba(59, 130, 246, 0.2); }
.status-confirmed { background: var(--success-soft); color: var(--success); border-color: rgba(16, 185, 129, 0.2); }
.status-cancelled { background: var(--danger-soft); color: var(--danger); border-color: rgba(239, 68, 68, 0.2); }
.status-hold      { background: var(--warning-soft); color: var(--warning); border-color: rgba(245, 158, 11, 0.2); }

/* ============================================================
   Security type radio (NORMAL / SECURE) — 견적 등록 폼
   ============================================================ */

.security-type-option > div {
    transition: border-color var(--duration) var(--ease),
                background-color var(--duration) var(--ease);
}

.security-type-option input[type="radio"]:checked + div {
    border-color: var(--brand) !important;
    background: var(--brand-soft);
    box-shadow: 0 0 0 1px var(--brand);
}

.security-type-option:hover > div {
    border-color: var(--text-secondary) !important;
}

.security-type-option input[type="radio"]:checked + div i.fa-shield-alt {
    color: var(--brand) !important;
}

/* ============================================================
   Security badge (목록 표시용)
   ============================================================ */

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid;
    margin-left: 6px;
    vertical-align: middle;
}

.security-badge-secure {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: rgba(30, 58, 95, 0.2);
}

.security-badge-secure i {
    font-size: 10px;
}
