@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

* {
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --success: #10b981;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

body {
    margin: 0;
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* Header & Navigation */
.header {
    background: white;
    padding: 0 40px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.top-nav {
    display: flex;
    gap: 10px;
    height: 100%;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0 20px;
    color: var(--text-muted);
    font-weight: 700;
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

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

.menu-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 70px);
}

.sidebar {
    background: white;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 24px 40px;
    background: var(--bg-main);
}

.summary-bar {
    display: flex;
    gap: 20px;
}

.summary-card {
    flex: 1;
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.summary-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Search & Control Bar */
.search-bar-container {
    padding: 15px 40px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-search-box {
    position: relative;
    width: 350px;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--bg-main);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Selection Bar */
.selection-bar {
    background: var(--primary-light);
    padding: 12px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

/* List Table Styles */
.member-list {
    flex: 1;
    overflow-y: auto;
}

.list-row {
    display: flex;
    align-items: center;
    padding: 12px 40px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.1s;
}

.list-row:hover {
    background: #f8fafc;
}

.list-row.active {
    background: var(--primary-light);
}

.list-header {
    background: #f8fafc;
    font-weight: 700;
    color: var(--text-muted);
    cursor: default;
    position: sticky;
    top: 0;
    z-index: 10;
}

.col-check {
    width: 30px;
}

.col-name {
    width: 80px;
    font-weight: 700;
}

.col-batch {
    width: 60px;
}

.col-branch {
    width: 80px;
}

.col-phone {
    width: 130px;
}

.col-date {
    width: 110px;
}

.col-manager {
    width: 90px;
}

.col-pay {
    width: 60px;
    text-align: center;
}

.col-note {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
}

/* Card & Info */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px 25px;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 700;
}

.info-item span {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-main);
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

/* Visit Log */
.log-item {
    position: relative;
    padding: 20px;
    border-radius: 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    margin-bottom: 15px;
}

.log-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.log-item:hover .log-actions {
    opacity: 1;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text-muted);
}

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

.btn-icon.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--border);
    gap: 1px;
    border-bottom: 1px solid var(--border);
}

.calendar-day-header {
    background: #f8fafc;
    padding: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calendar-cell {
    background: white;
    min-height: 120px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.calendar-cell.other-month {
    background: #fcfcfc;
}

.calendar-cell.other-month .day-number {
    color: #cbd5e1;
}

.day-number {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 5px;
}

.calendar-cell.today {
    background: var(--primary-light);
}

.calendar-cell.today .day-number {
    color: var(--primary);
    background: white;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.event-item {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fef2f2;
    color: var(--danger);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid var(--danger);
}

.event-item.discharged {
    background: #ecfdf5;
    color: var(--success);
    border-left-color: var(--success);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header {
        padding: 0 15px;
        height: 60px;
    }

    .header-title {
        font-size: 1.1rem;
    }

    .menu-item {
        padding: 0 10px;
        font-size: 0.85rem;
    }

    .sidebar-header,
    .search-bar-container,
    .selection-bar,
    .list-row {
        padding-left: 15px;
        padding-right: 15px;
    }

    .search-bar-container {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .header-search-box {
        width: 100%;
    }

    /* Prevent text wrapping in list */
    .member-list {
        overflow-x: auto;
    }

    .list-row {
        min-width: 800px;
        /* Force minimum width to prevent collapse */
        font-size: 0.82rem;
    }

    .summary-bar {
        flex-direction: column;
        gap: 10px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95vw;
        padding: 20px;
        margin: 10px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    /* Calendar adjustments */
    .calendar-cell {
        min-height: 80px;
        padding: 5px;
    }

    .day-number {
        font-size: 0.8rem;
    }

    .event-item {
        font-size: 0.65rem;
        padding: 1px 4px;
    }

    /* Inventory adjustments */
    #inventory-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Login Page Styles */
.login-body {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

.login-container {
    background: white;
    padding: 50px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 25px;
}

.login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s;
    background: #f8fafc;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.login-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.login-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #fee2e2;
}

/* Address Table (Spreadsheet Style) */
.address-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.address-table th {
    background: #f8fafc;
    padding: 12px 15px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.address-table td {
    border-bottom: 1px solid var(--border);
    padding: 0;
}

.address-table input {
    width: 100%;
    height: 100%;
    padding: 12px 15px;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    background: transparent;
    transition: background 0.1s;
}

.address-table input:focus {
    outline: 2px solid var(--primary);
    background: white;
    box-shadow: inset 0 0 0 1px var(--primary);
    z-index: 1;
}

.address-table tr:hover input {
    background: var(--bg-main);
}

.address-table input:focus {
    background: white !important;
}