/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

/* Define a modern color palette */
:root {
    --primary-color: #4a90e2;      /* A calm, professional blue */
    --primary-hover-color: #357ABD;
    --secondary-color: #50e3c2;    /* A fresh, vibrant mint for success/positive actions */
    --accent-color: #e74c3c;        /* Kept your original red for 'cash out' or warnings */
    --accent-hover-color: #c0392b;
    --history-color: #8e44ad;       /* Kept your original purple for history */
    --history-hover-color: #7b2c9f;
    --background-light: #f4f7fa;   /* A lighter, cleaner background */
    --container-bg: #ffffff;
    --text-dark: #333;
    --text-light: #fdfdfd;
    --border-color: #e1e5e8;
    --shadow-color: rgba(60, 64, 72, 0.1);
}

body {
    font-family: 'Poppins', 'Arial', sans-serif;
    background-color: var(--background-light);
    margin: 0;
    padding: 0;
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: 30px auto;
    padding: 30px;
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
}

h1 {
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 15px;
    font-size: 2.2rem;
    font-weight: 700;
}

h2 {
    color: var(--primary-color);
    text-align: center;
    font-size: 1.7rem;
    font-weight: 600;
    margin-bottom: 25px;
}

/* Flash Messages */
.flashed-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    color: var(--text-light);
    text-align: center;
    font-weight: 600;
}

.alert-success {
    background-color: var(--secondary-color);
    color: var(--text-dark); /* Mint is light, so dark text is more readable */
}

.alert-info {
    background-color: var(--primary-color);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    background-color: var(--border-color);
    border-radius: 30px;
    overflow: hidden;
    height: 30px;
    margin: 25px 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-hover-color), var(--primary-color));
    color: var(--text-light);
    text-align: center;
    line-height: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: width 0.5s ease-in-out;
}

/* Cash Out Button */
.cash-out-btn {
    display: block;
    width: 220px;
    margin: 25px auto;
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: var(--text-light);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.cash-out-btn:hover {
    background-color: var(--accent-hover-color);
    transform: translateY(-2px);
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 25px;
}

th, td {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

thead th {
    background-color: var(--primary-color);
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

tbody td {
    font-size: 0.95rem;
    color: #555;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: #f7f9fc;
}

tbody tr:last-child td {
    border-bottom: none;
}
    
/* History Section */
.history-section {
    margin-top: 50px;
    border-top: 2px solid var(--border-color);
    padding-top: 30px;
}

.history-section h2 {
    color: var(--history-color);
}

.history-section thead th {
    background-color: var(--history-color);
}

/* --- Mobile Responsive Styles --- */
@media (max-width: 768px) {
    .container {
        width: 100%;
        margin: 0;
        padding: 15px; /* Added padding to prevent touching edges */
        border-radius: 0;
        box-shadow: none;
        box-sizing: border-box; /* Important for padding calculation */
    }

    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.4rem; }

    .cash-out-btn {
        width: 100%; /* Full-width for easy tapping */
    }

    /* Progress bar text fix */
    .progress {
        box-sizing: border-box;
        padding: 0 10px;
        text-align: left; /* Align text left to ensure it's visible */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis; /* Add ... if text gets cut off */
    }
    
    /* Transform Table for Mobile */
    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
    }

    td {
        padding: 12px 15px;
        border: none;
        border-bottom: 1px solid var(--border-color);
        display: flex; /* Use flexbox for alignment */
        align-items: center; /* Vertically center label and value */
        justify-content: flex-start; /* Align items to the start */
    }

    td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-dark);
        width: 110px; /* Give the label a fixed width */
        flex-shrink: 0; /* Prevent the label from shrinking if data is long */
        text-align: left;
        padding-right: 15px; /* Space between label and value */
    }
    
    td:last-child {
        border-bottom: none;
    }
}
