/* ============================================
   EstiMATE - 견적 요청/제출 플랫폼
   Dark theme with glassmorphism
   ============================================ */

:root {
    --est-bg: var(--ph-bg, #08080d);
    --est-surface: var(--ph-bg-surface, rgba(255, 255, 255, 0.03));
    --est-surface-hover: var(--ph-bg-surface-hover, rgba(255, 255, 255, 0.06));
    --est-border: var(--ph-border, rgba(255, 255, 255, 0.08));
    --est-border-hover: var(--ph-border-hover, rgba(255, 255, 255, 0.15));
    --est-text: var(--ph-text, #F0F0F5);
    --est-text-muted: var(--ph-text-muted, rgba(240, 240, 245, 0.5));
    --est-text-subtle: var(--ph-text-subtle, rgba(240, 240, 245, 0.35));
    --est-primary: var(--ph-mint, #5CC6C3);
    --est-accent: var(--ph-purple, #8B6FA8);
    --est-error: var(--ph-error, #f87171);
    --est-success: var(--ph-success, #10b981);
    --est-warning: #f59e0b;
    --est-font: var(--ph-font-body, 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif);
}

/* ============================================
   PAGE LAYOUT
   ============================================ */
.est-app {
    min-height: 100vh;
    padding: 2rem;
    padding-top: 5rem;
}

.est-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Page Header */
.est-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 4rem 0 3rem;
}

.est-title {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--est-text);
    margin-bottom: 0.25rem;
}

.est-title em {
    font-style: italic;
    color: var(--est-primary);
}

.est-subtitle {
    font-size: 0.8rem;
    color: var(--est-text-muted);
    letter-spacing: 0.1em;
}

/* ============================================
   TOOLBAR
   ============================================ */
.est-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.est-write-btn {
    display: none;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    font-family: var(--est-font);
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    background: linear-gradient(135deg, var(--est-primary), var(--est-accent));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.est-write-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px -4px rgba(92, 198, 195, 0.4);
}

.est-write-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* ============================================
   REQUEST LIST
   ============================================ */
.est-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.est-list-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--est-text-muted);
    font-size: 0.9rem;
}

.est-list-empty svg {
    width: 48px;
    height: 48px;
    stroke: var(--est-text-subtle);
    stroke-width: 1.5;
    fill: none;
    margin-bottom: 1rem;
}

.est-card {
    position: relative;
    padding: 1.25rem 1.5rem;
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.est-card:hover {
    background: var(--est-surface-hover);
    border-color: var(--est-border-hover);
    transform: translateY(-1px);
}

.est-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.est-card__date {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--est-text);
}

.est-card__status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: 100px;
}

.est-card__status--open {
    color: var(--est-success);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.est-card__status--closed {
    color: var(--est-text-subtle);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--est-border);
}

.est-card__location {
    font-size: 0.8rem;
    color: var(--est-text-muted);
    margin-bottom: 0.5rem;
}

.est-card__categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.est-card__cat-tag {
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    color: var(--est-primary);
    background: rgba(92, 198, 195, 0.08);
    border: 1px solid rgba(92, 198, 195, 0.15);
    border-radius: 100px;
}

.est-card__meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.7rem;
    color: var(--est-text-subtle);
}

.est-card__meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.est-card__meta svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* ============================================
   REQUEST DETAIL
   ============================================ */
.est-detail {
    display: none;
}

.est-detail__back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: var(--est-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.est-detail__back:hover { color: var(--est-text); }

.est-detail__back svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.est-detail__header {
    padding: 1.5rem;
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.est-detail__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.est-detail__field {
    margin-bottom: 1rem;
}

.est-detail__field:last-child { margin-bottom: 0; }

.est-detail__label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--est-text-subtle);
    margin-bottom: 0.35rem;
}

.est-detail__value {
    font-size: 0.9rem;
    color: var(--est-text);
    line-height: 1.6;
    white-space: pre-wrap;
}

.est-detail__attachments {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.est-detail__file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    color: var(--est-primary);
    background: rgba(92, 198, 195, 0.06);
    border: 1px solid rgba(92, 198, 195, 0.15);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.est-detail__file-link:hover {
    background: rgba(92, 198, 195, 0.12);
}

.est-detail__file-link svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* 견적 제출 버튼 (Vendor용) */
.est-submit-proposal-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
    padding: 0.7rem 1.5rem;
    font-family: var(--est-font);
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--est-primary), var(--est-accent));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.est-submit-proposal-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px -4px rgba(92, 198, 195, 0.4);
}

.est-submit-proposal-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* 요청 삭제/마감 버튼 */
.est-detail__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.est-close-btn {
    padding: 0.5rem 1rem;
    font-family: var(--est-font);
    font-size: 0.8rem;
    color: var(--est-text-muted);
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.est-close-btn:hover {
    border-color: var(--est-border-hover);
    color: var(--est-text);
}

/* ============================================
   PROPOSAL LIST (in detail view)
   ============================================ */
.est-proposals {
    margin-top: 1.5rem;
}

.est-proposals__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--est-text);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.est-proposals__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: var(--est-primary);
    border-radius: 100px;
}

.est-proposal-card {
    padding: 1rem 1.25rem;
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.est-proposal-card:hover {
    background: var(--est-surface-hover);
    border-color: var(--est-border-hover);
}

.est-proposal-card.expanded {
    border-color: rgba(92, 198, 195, 0.2);
}

.est-proposal-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.est-proposal-card__company {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--est-text);
}

.est-proposal-card__date {
    font-size: 0.7rem;
    color: var(--est-text-subtle);
}

/* ============================================
   PROPOSAL DETAIL (inline expand)
   ============================================ */
.est-proposal-expand {
    display: none;
    padding-top: 1rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--est-border);
}

.est-proposal-expand.show { display: block; }

.est-proposal-expand__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.est-proposal-expand__field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.est-proposal-expand__label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--est-text-subtle);
}

.est-proposal-expand__value {
    font-size: 0.85rem;
    color: var(--est-text);
}

.est-proposal-expand__message {
    margin-bottom: 1rem;
}

.est-proposal-expand__message-text {
    font-size: 0.85rem;
    color: var(--est-text-muted);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 상태 뱃지 */
.est-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 100px;
    letter-spacing: 0.03em;
}

.est-status-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.est-status-badge--pending {
    color: #9ca3af;
    background: rgba(156, 163, 175, 0.1);
}

.est-status-badge--reviewing {
    color: var(--est-warning);
    background: rgba(245, 158, 11, 0.1);
}

.est-status-badge--approved {
    color: var(--est-success);
    background: rgba(16, 185, 129, 0.1);
}

.est-status-badge--rejected {
    color: var(--est-error);
    background: rgba(248, 113, 113, 0.1);
}

/* 상태 변경 드롭다운 */
.est-status-select {
    padding: 0.3rem 0.6rem;
    font-family: var(--est-font);
    font-size: 0.75rem;
    color: var(--est-text);
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 6px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.est-status-select:focus {
    border-color: var(--est-primary);
}

/* ============================================
   MODAL (Editor)
   ============================================ */
.est-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.est-modal-overlay.show {
    display: flex;
}

.est-modal {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--est-bg);
    border: 1px solid var(--est-border);
    border-radius: 16px;
    padding: 1.5rem;
}

.est-modal::-webkit-scrollbar {
    width: 4px;
}

.est-modal::-webkit-scrollbar-track {
    background: transparent;
}

.est-modal::-webkit-scrollbar-thumb {
    background: var(--est-border);
    border-radius: 4px;
}

.est-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.est-modal__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--est-text);
}

.est-modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--est-border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--est-text-muted);
    transition: all 0.2s;
}

.est-modal__close:hover {
    border-color: var(--est-border-hover);
    color: var(--est-text);
}

.est-modal__close svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.est-form-group {
    margin-bottom: 1.25rem;
}

.est-form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--est-text-muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.03em;
}

.est-form-label .required {
    color: var(--est-error);
    margin-left: 0.15rem;
}

.est-form-input,
.est-form-textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    font-family: var(--est-font);
    font-size: 0.85rem;
    color: var(--est-text);
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.est-form-input:focus,
.est-form-textarea:focus {
    border-color: var(--est-primary);
}

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

.est-form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.est-form-hint {
    display: flex;
    justify-content: space-between;
    margin-top: 0.3rem;
    font-size: 0.7rem;
    color: var(--est-text-subtle);
}

/* 날짜 range */
.est-date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.est-date-range input[type="date"] {
    flex: 1;
}

.est-date-range__sep {
    color: var(--est-text-subtle);
    font-size: 0.8rem;
}

/* 카테고리 체크박스 */
.est-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.est-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--est-text-muted);
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.est-checkbox-item:hover {
    border-color: var(--est-border-hover);
}

.est-checkbox-item.checked {
    color: var(--est-primary);
    background: rgba(92, 198, 195, 0.08);
    border-color: rgba(92, 198, 195, 0.25);
}

.est-checkbox-item input[type="checkbox"] {
    display: none;
}

/* 파일 드래그앤드롭 영역 */
.est-dropzone {
    position: relative;
    padding: 1.5rem;
    text-align: center;
    background: var(--est-surface);
    border: 2px dashed var(--est-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.est-dropzone:hover,
.est-dropzone.dragover {
    border-color: var(--est-primary);
    background: rgba(92, 198, 195, 0.04);
}

.est-dropzone__icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--est-text-subtle);
    stroke-width: 1.5;
    fill: none;
    margin-bottom: 0.5rem;
}

.est-dropzone__text {
    font-size: 0.8rem;
    color: var(--est-text-muted);
}

.est-dropzone__hint {
    font-size: 0.7rem;
    color: var(--est-text-subtle);
    margin-top: 0.25rem;
}

.est-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* 선택된 파일 목록 */
.est-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.est-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.6rem;
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--est-text-muted);
}

.est-file-item__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.est-file-item__size {
    color: var(--est-text-subtle);
    margin: 0 0.5rem;
    white-space: nowrap;
}

.est-file-item__remove {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--est-text-subtle);
    transition: color 0.2s;
    padding: 0;
}

.est-file-item__remove:hover { color: var(--est-error); }

.est-file-item__remove svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* 제출 버튼 */
.est-form-submit {
    width: 100%;
    padding: 0.75rem;
    font-family: var(--est-font);
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--est-primary), var(--est-accent));
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.est-form-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px -4px rgba(92, 198, 195, 0.4);
}

.est-form-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   PAGINATION
   ============================================ */
.est-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 2rem;
}

.est-pagination button {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.5rem;
    font-family: var(--est-font);
    font-size: 0.75rem;
    color: var(--est-text-muted);
    background: var(--est-surface);
    border: 1px solid var(--est-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.est-pagination button:hover:not(:disabled) {
    border-color: var(--est-border-hover);
    color: var(--est-text);
}

.est-pagination button.active {
    color: var(--est-primary);
    border-color: var(--est-primary);
    background: rgba(92, 198, 195, 0.08);
}

.est-pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================
   TOAST
   ============================================ */
.est-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.7rem 1.5rem;
    font-size: 0.85rem;
    color: #fff;
    background: rgba(30, 30, 40, 0.95);
    border: 1px solid var(--est-border);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s ease;
    pointer-events: none;
    white-space: nowrap;
}

.est-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.est-toast.error {
    border-color: rgba(248, 113, 113, 0.3);
}

/* ============================================
   ACCESS DENIED
   ============================================ */
.est-access-denied {
    display: none;
    text-align: center;
    padding: 6rem 2rem;
}

.est-access-denied svg {
    width: 56px;
    height: 56px;
    stroke: var(--est-text-subtle);
    stroke-width: 1.5;
    fill: none;
    margin-bottom: 1rem;
}

.est-access-denied__text {
    font-size: 1rem;
    color: var(--est-text-muted);
    margin-bottom: 0.5rem;
}

.est-access-denied__hint {
    font-size: 0.8rem;
    color: var(--est-text-subtle);
}

/* ============================================
   LOADING
   ============================================ */
.est-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.est-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--est-border);
    border-top-color: var(--est-primary);
    border-radius: 50%;
    animation: est-spin 0.8s linear infinite;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .est-app {
        padding: 1rem;
        padding-top: 4rem;
    }

    .est-container {
        max-width: 100%;
    }

    .est-modal {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .est-date-range {
        flex-direction: column;
        gap: 0.5rem;
    }

    .est-date-range__sep { display: none; }

    .est-proposal-expand__grid {
        grid-template-columns: 1fr;
    }

    .est-card__top {
        flex-direction: column;
        gap: 0.5rem;
    }
}
