/* ==========================================================================
   DESIGN SYSTEM - WARM BEIGE GLASSMORPHISM THEME
   ========================================================================== */
:root {
    /* Color Palette */
    --bg-base: #FAF6F0;          /* Warm Milk/Beige background */
    --bg-sidebar: #F2EBE1;       /* Darker warm sand for sidebar */
    --bg-card: rgba(255, 255, 255, 0.72); /* Glassmorphism translucent white */
    --bg-card-hover: rgba(255, 255, 255, 0.85);
    
    --primary: #C27D38;          /* Rice Gold / Warm Amber */
    --primary-light: #E6A767;
    --primary-dark: #995B20;
    --primary-bg: #FDF6EC;

    --success: #3F7A60;          /* Deep Emerald / Cash In */
    --success-light: #64A387;
    --success-bg: #EBF5F0;

    --danger: #BD534C;           /* Soft Terracotta / Out */
    --danger-light: #DB7C76;
    --danger-bg: #FDF2F1;

    --text-main: #3D352E;        /* Warm Dark Slate Brown */
    --text-muted: #7A6F65;       /* Muted Earth Gray */
    --border-color: rgba(194, 125, 56, 0.15); /* Warm light border */
    --border-focus: #C27D38;

    /* Shadow system */
    --shadow-sm: 0 2px 8px rgba(61, 53, 46, 0.04);
    --shadow-md: 0 8px 24px rgba(61, 53, 46, 0.06);
    --shadow-lg: 0 16px 40px rgba(61, 53, 46, 0.08);
    --shadow-glass: 0 8px 32px 0 rgba(122, 111, 101, 0.07);

    /* Fonts */
    --font-thai: 'Noto Sans Thai', sans-serif;
    --font-eng: 'Montserrat', sans-serif;

    /* Layout & Spacing */
    --sidebar-width: 280px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-thai);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-thai);
    font-weight: 600;
    color: var(--text-main);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(122, 111, 101, 0.25);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(122, 111, 101, 0.4);
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid rgba(194, 125, 56, 0.1);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2.5rem;
}

.logo-icon {
    color: var(--primary);
    width: 2.2rem;
    height: 2.2rem;
    stroke-width: 2.5;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--primary-dark);
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: none;
    border: none;
    padding: 0.9rem 1.2rem;
    border-radius: 12px;
    color: var(--text-muted);
    font-family: var(--font-thai);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
    width: 100%;
}

.nav-item i {
    width: 1.2rem;
    height: 1.2rem;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--primary-dark);
    background-color: rgba(194, 125, 56, 0.08);
}

.nav-item.active {
    color: #fff;
    background-color: var(--primary);
    box-shadow: 0 4px 14px rgba(194, 125, 56, 0.25);
}

.nav-item.active i {
    transform: scale(1.1);
}

.sidebar-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(194, 125, 56, 0.1);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-footer p {
    margin-bottom: 0.4rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
    color: var(--success);
    background-color: var(--success-bg);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}

.status-badge .dot {
    width: 6px;
    height: 6px;
    background-color: var(--success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.5; }
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2rem 2.5rem;
    width: calc(100% - var(--sidebar-width));
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(194, 125, 56, 0.08);
}

.header-title h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

.datetime-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.6);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.datetime-display i {
    width: 1rem;
    height: 1rem;
    color: var(--primary);
}

/* ==========================================================================
   CONTENT SECTIONS
   ========================================================================== */
.content-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

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

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

/* ==========================================================================
   STATS CARDS GRID
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: var(--shadow-glass);
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    background: var(--bg-card-hover);
}

.stat-icon-wrapper {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-wrapper i {
    width: 1.8rem;
    height: 1.8rem;
}

/* Color codes for stat icons */
.stat-icon-wrapper.stock {
    background-color: var(--primary-bg);
    color: var(--primary);
}

.stat-icon-wrapper.balance {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-icon-wrapper.spent {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.stat-icon-wrapper.income {
    background-color: var(--success-bg);
    color: var(--success);
}

.stat-info {
    flex-grow: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-family: var(--font-eng), var(--font-thai);
    font-weight: 700;
    margin: 0.2rem 0;
}

.stat-value .unit {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-subtext {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* ==========================================================================
   DASHBOARD / CARDS LAYOUT
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

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

.dashboard-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

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

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(194, 125, 56, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-body {
    padding: 1.5rem;
    position: relative;
    flex-grow: 1;
}

.chart-container {
    min-height: 320px;
    height: 320px;
}

/* Stock breakdown layout */
.stock-breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stock-item {
    background-color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(194, 125, 56, 0.05);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: var(--transition-smooth);
}

.stock-item:hover {
    background-color: rgba(255, 255, 255, 0.8);
    border-color: rgba(194, 125, 56, 0.15);
}

.stock-item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stock-item-weight {
    font-family: var(--font-eng), var(--font-thai);
    font-weight: 700;
    font-size: 1.1rem;
}

.stock-progress-bar-bg {
    background-color: rgba(194, 125, 56, 0.08);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

.stock-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.stock-avg-prices {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stock-avg-prices span strong {
    color: var(--text-main);
}

/* ==========================================================================
   ENTRY PAGE LAYOUT & FORMS
   ========================================================================== */
.entry-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .entry-layout {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group.hidden {
    display: none;
}

label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-input, .form-select, .form-select-sm {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-thai);
    font-size: 0.95rem;
    border: 1.5px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    color: var(--text-main);
    transition: var(--transition-smooth);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-select-sm:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(194, 125, 56, 0.15);
    background-color: #fff;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-unit-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-unit-group .form-input {
    padding-right: 3rem;
}

.input-unit {
    position: absolute;
    right: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.price-indicator {
    background-color: var(--primary-bg);
    border: 1px dashed rgba(194, 125, 56, 0.3);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-top: 1rem;
    color: var(--primary-dark);
}

.price-indicator.success {
    background-color: var(--success-bg);
    border-color: rgba(63, 122, 96, 0.3);
    color: var(--success);
}

.price-indicator strong {
    font-family: var(--font-eng), var(--font-thai);
    font-size: 1.25rem;
}

.stock-info-badge {
    background-color: #f7ede2;
    color: #a06018;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    display: inline-block;
}

.stock-info-badge.hidden {
    display: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-thai);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(194, 125, 56, 0.2);
}

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

.btn-success:hover {
    background-color: #2f5d49;
    box-shadow: 0 4px 12px rgba(63, 122, 96, 0.2);
}

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

.btn-danger:hover {
    background-color: #9f3c36;
    box-shadow: 0 4px 12px rgba(189, 83, 76, 0.2);
}

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

.btn-outline:hover {
    background-color: rgba(194, 125, 56, 0.06);
    border-color: var(--primary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

.pointer {
    cursor: pointer;
}

.w-100 { width: 100%; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.overflow-x { overflow-x: auto; }
.flex-wrap { display: flex; flex-wrap: wrap; }
.gap-4 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ==========================================================================
   RECENT TRANSACTION LISTS
   ========================================================================== */
.recent-list-container {
    max-height: 380px;
    overflow-y: auto;
}

.recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-item {
    background-color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(194, 125, 56, 0.06);
    border-radius: 12px;
    padding: 0.9rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
}

.recent-item:hover {
    background-color: #fff;
    box-shadow: var(--shadow-sm);
    border-color: rgba(194, 125, 56, 0.15);
}

.recent-info h5 {
    font-size: 0.95rem;
    font-weight: 600;
}

.recent-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.recent-numbers {
    text-align: right;
}

.recent-weight {
    font-family: var(--font-eng), var(--font-thai);
    font-weight: 700;
    font-size: 1.05rem;
}

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

.recent-item.buy {
    border-left: 4px solid var(--primary);
}

.recent-item.sell {
    border-left: 4px solid var(--success);
}

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

/* ==========================================================================
   TABLES
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.92rem;
}

.data-table th {
    background-color: rgba(194, 125, 56, 0.05);
    color: var(--text-main);
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(194, 125, 56, 0.1);
}

.data-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(194, 125, 56, 0.05);
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition-smooth);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

/* Table specific styling classes */
.badge-type {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}

.badge-type.buy {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
}

.badge-type.sell {
    background-color: var(--success-bg);
    color: var(--success);
}

.btn-delete-row {
    background: none;
    border: none;
    color: var(--danger-light);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-delete-row:hover {
    color: var(--danger);
    background-color: var(--danger-bg);
}

/* ==========================================================================
   FILTERS AREA
   ========================================================================== */
.filter-group {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.filter-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0;
    text-transform: uppercase;
}

.filter-item select {
    min-width: 140px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.data-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ==========================================================================
   RESPONSIVE DESIGN ADAPTATIONS
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 1.5rem 0.5rem;
        align-items: center;
    }
    
    .logo-text, .sidebar-footer, .nav-item span {
        display: none;
    }
    
    .logo-area {
        justify-content: center;
        margin-bottom: 2rem;
    }
    
    .nav-item {
        justify-content: center;
        padding: 0.9rem;
    }

    .main-content {
        margin-left: 70px;
        width: calc(100% - 70px);
        padding: 1.5rem 1.25rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .datetime-display {
        width: 100%;
        justify-content: center;
    }
}
