:root {
    --primary: #4a90e2;
    --primary-dark: #357abd;
    --secondary: #f5f7fa;
    --accent: #ffcc00;
    --danger: #ff4d4d;
    --warning: #ffa500;
    --success: #2ecc71;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #dcdde1;
    --bg-app: #f0f2f5;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.hidden {
    display: none !important;
}

/* Header */
header {
    background-color: var(--white);
    padding: 0.8rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.3rem;
    color: var(--primary);
    font-weight: 700;
}

nav {
    display: flex;
    gap: 12px;
}

.nav-link {
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 4px;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
}

/* Main Content */
main {
    padding: 1.5rem 0;
    min-height: calc(100vh - 140px);
}

.view {
    animation: fadeIn 0.4s ease;
}

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

/* Home View - Fridge Graphic */
.fridge-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
    text-align: center;
}

.fridge-graphic {
    width: 260px;
    height: 460px;
    background-color: #e1e8ed;
    border: 6px solid #cbd5e0;
    border-radius: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.fridge-top, .fridge-bottom {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.fridge-top {
    background-color: #edf2f7;
    border-bottom: 3px solid #cbd5e0;
}

.fridge-bottom {
    background-color: #f7fafc;
    flex: 1.5;
}

.fridge-top:hover, .fridge-bottom:hover {
    background-color: var(--white);
}

.fridge-top span, .fridge-bottom span {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.open-btn {
    padding: 6px 14px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(74, 144, 226, 0.3);
}

.fridge-actions h2 {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}

.fridge-actions p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    padding: 0 20px;
}

/* List View */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-group h2 {
    font-size: 1.4rem;
}

/* Table Styles - Enhanced for Mobile */
.table-container {
    background-color: var(--white);
    border-radius: var(--radius);
    overflow-x: auto;
    position: relative;
    border: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
}

/* 가로 스크롤 암시를 위한 쉐도우 */
.table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 20px;
    background: linear-gradient(to left, rgba(0,0,0,0.05), transparent);
    pointer-events: none;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    min-width: 900px; /* 테이블 최소 너비 확보 */
}

th, td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sticky Column for Mobile */
thead th:first-child,
tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: inherit;
    border-right: 2px solid var(--border-color);
}

thead th:first-child {
    z-index: 20;
    background-color: #f8fafc;
}

tbody tr:nth-child(even) td:first-child {
    background-color: #f9fafb;
}

tbody tr:hover td:first-child {
    background-color: #f1f5f9;
}

thead th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    position: relative;
    cursor: pointer;
    user-select: none;
}

thead th i {
    width: 14px;
    height: 14px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Resizer */
.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    cursor: col-resize;
    height: 100%;
}

/* Buttons */
.primary-btn {
    background-color: var(--primary);
    color: var(--white);
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.primary-btn:active {
    transform: scale(0.98);
}

.icon-btn {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

/* FAB (Floating Action Button) - Visible only on mobile */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background-color: var(--primary);
    color: var(--white);
    display: none; /* Desktop hidden */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
    border: none;
    z-index: 90;
    cursor: pointer;
    transition: var(--transition);
}

.fab:active {
    transform: scale(0.9) rotate(90deg);
}

/* Warning Styles */
.stock-warning {
    color: var(--danger);
    font-weight: 700;
    background-color: #fff5f5;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    align-items: flex-end; /* Bottom sheet for mobile */
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--white);
    width: 100%;
    max-width: 600px;
    border-radius: 20px 20px 0 0; /* Rounded top for bottom sheet */
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 5;
}

/* Responsive Styles */
@media (min-width: 769px) {
    .fridge-container {
        flex-direction: row;
        gap: 60px;
        padding: 3rem 0;
    }
    
    .fridge-graphic {
        width: 300px;
        height: 540px;
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        max-height: 85vh;
    }
    
    .action-group .primary-btn {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    #logo span { display: none; } /* Show only icon on very small? No, keep it. */
    
    .action-group .primary-btn {
        display: none; /* Hide standard add button, use FAB */
    }
    
    .fab {
        display: flex;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group.full {
        grid-column: span 1;
    }
    
    th, td {
        padding: 16px 12px; /* Bigger touch targets */
    }
}

/* Custom Scrollbar for Table */
.table-container::-webkit-scrollbar {
    height: 6px;
}
.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}
