/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600&display=swap');

:root {
    --bg-color: #0d0d0d;
    --card-bg: #1a1a1a;
    --primary-color: #7b2cbf;
    /* Deep Purple */
    --accent-color: #e0aaff;
    --text-color: #e0e0e0;
    --input-bg: #2a2a2a;
    --input-border: #333;
    --button-bg: #9d4edd;
    --button-hover: #c77dff;
}

* {
    box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

html {
    overflow-y: scroll;
    /* Force sidebar to maintain consistent width */
    overflow-x: hidden;
    /* Prevent horizontal shift */
}

body {
    margin: 0;
    overflow-x: hidden;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Main Container */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* Dashboard Grid Layout (Desktop Default) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(420px, 1.2fr) 1fr;
    /* Top row fixed min height, bottom row fills rest */
    gap: 20px;
    height: 100%;
    box-sizing: border-box;
    align-content: stretch;
}

.grid-stats {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

.grid-logs {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.grid-game {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    margin-top: 20px;
    /* Enhanced separation */
}

/* Card */
.login-card {
    background-color: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid #333;
}

/* Logo */
.logo {
    width: 150px;
    margin-bottom: 30px;
    object-fit: contain;
}

/* Typography */
h2 {
    margin-bottom: 10px;
    font-weight: 600;
    color: #fff;
}

.subtitle {
    font-size: 0.9em;
    color: #aaa;
    margin-bottom: 30px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #ccc;
    font-weight: 400;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: #fff;
    font-size: 1em;
    box-sizing: border-box;
    /* Important for padding */
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(123, 44, 191, 0.2);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--button-bg));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(157, 78, 221, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid #555;
    color: #ccc;
}

.btn-secondary:hover {
    border-color: #888;
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.4);
    transform: translateY(-2px);
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    font-size: 0.8em;
    color: #666;
    border-top: 1px solid #222;
    background-color: #111;
}

footer p {
    margin: 5px 0;
    line-height: 1.5;
}

footer .copyright {
    margin-top: 15px;
    color: #444;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .login-card {
        padding: 20px 15px;
        /* Reduced padding */
        box-shadow: none;
        background-color: transparent;
        border: none;
        width: 100%;
        /* Ensure full width */
    }

    .form-group {
        margin-bottom: 15px;
        /* Tighter spacing */
    }

    .form-control {
        padding: 14px;
        /* Larger touch target */
        font-size: 16px;
        /* Prevent zoom on iOS */
    }

    .btn {
        padding: 16px;
        /* Larger touch target */
        font-size: 1.1em;
    }

    .logo {
        width: 120px;
        /* Smaller logo */
        margin-bottom: 20px;
    }

    h2 {
        font-size: 1.5em;
        /* Smaller heading */
    }

    .subtitle {
        font-size: 0.85em;
        /* Smaller subtitle */
        margin-bottom: 25px;
    }

    footer {
        font-size: 0.7em;
        /* Smaller footer text */
        padding: 15px 10px;
    }
}

/* Register Page Specifics */
.register-card {
    max-width: 600px;
    /* Wider for register form */
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    /* Match form-group spacing */
}

.half-width {
    flex: 1;
    margin-bottom: 0;
    /* Reset margin inside row */
}

/* Adjust for small screens */
/* Adjust for small screens and tablets */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    .register-card {
        padding: 20px;
        /* Ensure padding exists on mobile even if background is transparent */
    }
}

/* Agreement Boxes */
/* Agreement Boxes */
.agreement-box {
    display: block;
    width: 100%;
    height: 120px;
    background-color: #252525;
    border: 1px solid #777;
    padding: 12px;
    overflow-y: scroll;
    margin-bottom: 8px;
    border-radius: 4px;
    text-align: left;
    box-sizing: border-box;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.agreement-check {
    text-align: left;
    margin-bottom: 20px;
    font-size: 0.9em;
    color: #ccc;
}

.agreement-check input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--primary-color);
}

/* Agreement Content Styles (from agree1.php) */
.clause-content {
    color: #ccc;
    font-family: inherit;
    /* Use global font */
    line-height: 1.6;
    font-size: 0.9em;
}

.clause-content .title {
    text-align: center;
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 5px;
    color: #fff;
}

.clause-content .subtitle {
    text-align: center;
    font-size: 0.9em;
    color: #aaa;
    margin-bottom: 20px;
}

.clause-content h2 {
    font-size: 1em;
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    color: #e0e0e0;
}

.clause-content p,
.clause-content li {
    font-size: 0.9em;
    line-height: 1.6;
    margin-bottom: 8px;
}

.clause-content ul {
    margin-left: 15px;
    padding-left: 0;
}

.clause-content li {
    list-style: none;
    margin-bottom: 5px;
}

.clause-content .date {
    text-align: right;
    margin-top: 20px;
    font-size: 0.85em;
    color: #aaa;
}


/* Operation Log Table & Show More */
.log-table tbody tr:nth-child(n+11) {
    display: none;
}

.log-table.expanded tbody tr:nth-child(n+11) {
    display: table-row;
}

.btn-show-more {
    display: block;
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #aaa;
    border: none;
    border-top: 1px solid #444;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-align: center;
}

.btn-show-more:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* --- Dashboard Layout --- */

/* Top Bar */
.top-bar {
    height: 60px;
    background-color: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.top-bar .brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-logo {
    height: 40px;
    object-fit: contain;
}

.shop-name {
    font-size: 1.2em;
    font-weight: 600;
    color: #fff;
}

.btn-logout {
    background-color: transparent;
    border: 1px solid #555;
    color: #ccc;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: #333;
    color: #fff;
    border-color: #888;
}

/* Dashboard Container */
.dashboard-container {
    display: flex;
    margin-top: 60px;
    /* Height of top-bar */
    height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: #151515;
    border-right: 1px solid #2a2a2a;
    flex-shrink: 0;
    overflow-y: auto;
}

.menu-list {
    list-style: none;
    padding: 20px 10px;
    /* Added horizontal padding */
    margin: 0;
}

.menu-item {
    margin-bottom: 10px;
    /* Spacing between buttons */
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    /* Space between icon and text */
    padding: 15px 20px;
    color: #aaa;
    text-decoration: none;
    font-size: 1.1em;
    /* Larger font */
    transition: all 0.2s;
    border-radius: 12px;
    /* Rounded corners */
    background-color: rgba(255, 255, 255, 0.03);
    /* Subtle background */
    border: 1px solid transparent;
}

.menu-item a:hover {
    background-color: #222;
    color: #fff;
    transform: translateY(-2px);
    /* Slight lift effect */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.menu-item.active a {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.2), rgba(123, 44, 191, 0.1));
    color: #fff;
    border: 1px solid var(--primary-color);
    font-weight: 600;
}


/* Content Area */
.content-area {
    flex: 1;
    background-color: var(--bg-color);
    /* Main BG */
    padding: 40px;
    overflow-y: auto;
}

.welcome-section h1 {
    font-size: 2em;
    margin-bottom: 10px;
    color: #fff;
}

.welcome-section p {
    color: #888;
}

.info-card {
    background-color: #1a1a1a;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    margin-top: 30px;
    display: inline-block;
    min-width: 300px;
}

.info-card p {
    color: #ccc;
    margin: 8px 0;
}


/* --- Responsive Dashboard (Mobile Top Menu) --- */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px);
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #333;
        overflow-x: auto;
        /* Horizontal scroll */
        white-space: nowrap;
        background-color: #1a1a1a;
        position: sticky;
        top: 60px;
        /* Below top bar */
        z-index: 900;
        padding-bottom: 0px;
        /* Reset padding */
    }

    .menu-list {
        display: flex;
        padding: 10px;
        gap: 10px;
    }

    .menu-item {
        margin-bottom: 0;
        flex: 0 0 auto;
        /* Don't shrink buttons */
    }

    .menu-item a {
        flex-direction: column;
        padding: 6px 12px;
        /* Reduced by ~25% */
        font-size: 0.85em;
        /* Reduced font size */
        border-radius: 16px;
        /* Slightly smaller radius */
        background-color: #252525;
        gap: 0;
        justify-content: center;
        height: auto;
        /* Let content define height to avoid cut-off */
        min-height: 36px;
        /* Ensure minimum touch target */
    }

    /* Hide icons on mobile as requested */
    .menu-icon {
        display: none !important;
    }

    .menu-item a:hover {
        transform: none;
        /* remove lift effect on touch */
    }

    /* Active state for mobile tabs */
    .menu-item.active a {
        background: var(--primary-color);
        color: #fff;
        border: none;
    }

    .content-area {
        padding: 5px;
        /* Reduced padding to minimize left margin gap */
        height: auto;
        overflow: visible;
    }

    .info-card {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
}

/* Navigation Buttons in Top Bar */
.btn-nav {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 5px;
    transition: all 0.2s;
}

.btn-nav:hover {
    background: #333;
    color: white;
    border-color: #888;
}

@media (max-width: 600px) {

    .btn-nav,
    .btn-logout {
        padding: 5px 8px;
        font-size: 0.8rem;
        margin-right: 0;
    }
}

/* Standardized Mobile Top Bar & Sidebar */
@media (max-width: 768px) {

    /* Shop Name Hide */
    /* Shop Name Hide - Removed as per request */
    /* .shop-name { display: none !important; } */

    /* Limit logo height on mobile */
    .top-logo {
        height: 32px;
        /* Smaller logic for mobile */
        width: auto;
    }

    /* Top Bar Layout */
    .top-bar {
        padding: 10px;
        height: auto;
        flex-wrap: wrap;
        gap: 10px;
        position: relative;
        /* Make it flow naturally on mobile */
        box-sizing: border-box;
        /* Prevent padding from adding to width */
        width: 100%;
    }

    .top-bar .brand {
        margin-right: auto;
    }

    .user-info {
        display: flex;
        gap: 5px;
        justify-content: flex-end;
        width: 100%;
        /* Stack below brand */
        margin-top: 0;
        margin-bottom: 0;
    }

    .btn-nav,
    .btn-logout {
        padding: 6px 10px;
        font-size: 0.8rem;
        flex: 1;
        /* Distribute space evenly */
        text-align: center;
        margin: 0;
    }

    .dashboard-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 60px);
        margin-top: 0;
        /* Remove fixed header spacing on mobile */
    }

    /* Restore Dashboard Grid Vertical Stacking */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 15px;
        height: auto;
    }

    .grid-stats,
    .grid-game,
    .grid-logs {
        grid-column: auto !important;
        grid-row: auto !important;
        width: 100%;
        height: auto;
        order: unset;
        /* Or set specific order if needed */
    }

    /* Log Table visibility adjustments removed from here to be global */

    .member-container {
        /* Also fix member container */
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 15px;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #333;
        overflow-x: auto;
        white-space: nowrap;
        background-color: #1a1a1a;
        position: sticky;
        top: 0;
        /* Sticky to top of container/below top-bar? Top bar is fixed at 0. Top bar height can vary now. */
        /* If top bar is fixed, we need to know its height. The existing main.php used top: 60px. */
        /* But since top-bar height is auto, adhering to 60px might be risky if it grows. */
        /* However, for now, let's stick to the main.php logic which tried 60px or similar. */
        /* Actually, in main.php style, top-bar is fixed. */
        top: 55px;
        /* Approximate height of collapsed top bar */
        z-index: 900;
        padding-bottom: 0px;
    }

    .menu-list {
        display: flex;
        padding: 10px;
        gap: 10px;
    }
}

/* Member Management Desktop/Global Styles */
.member-container {
    display: flex;
    height: calc(100vh - 60px);
    padding: 20px;
    gap: 20px;
    box-sizing: border-box;
}

.panel-left,
.panel-right {
    flex: 1;
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.search-area {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #444;
    background: #333;
    color: white;
    border-radius: 4px;
}

.member-list-wrapper {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 4px;
}

.member-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.member-table th {
    background: #333;
    position: sticky;
    top: 0;
    padding: 10px;
    border-bottom: 1px solid #555;
    color: #ddd;
    z-index: 1;
}

.member-table td {
    padding: 10px;
    border-bottom: 1px solid #444;
    color: #ccc;
    text-align: center;
    cursor: pointer;
}

.member-table tr:hover td {
    background: #444;
}

.member-table tr.active td {
    background: #555;
    color: white;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.detail-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.form-label {
    width: 100px;
    color: #aaa;
    font-size: 0.9rem;
}

.form-input-container {
    flex: 1;
    display: flex;
    gap: 10px;
}

.form-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #555;
    background: #222;
    color: white;
    border-radius: 4px;
}

.form-input[readonly] {
    background: #111;
    color: #888;
}

.btn-action,
.btn-add-member {
    padding: 10px 15px;
    background: linear-gradient(135deg, var(--primary-color), var(--button-bg));
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-save {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: auto;
    align-self: flex-end;
}

.memo-area {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 1px solid #555;
    background: #222;
    color: white;
    border-radius: 4px;
    resize: none;
}

/* Hide Memo Column on Mobile */
@media (max-width: 768px) {

    .member-table th:nth-child(4),
    .member-table td:nth-child(4) {
        display: none;
    }
}

/* Mobile Overrides (Appended to ensure cascade) */
@media (max-width: 768px) {

    /* Restore Mobile Menu Items (moved from main block) */
    .menu-item {
        margin-bottom: 0;
        flex: 0 0 auto;
    }

    .menu-item a {
        flex-direction: column;
        padding: 6px 12px;
        font-size: 0.85em;
        border-radius: 16px;
        background-color: #252525;
        gap: 0;
        justify-content: center;
        height: auto;
        min-height: 36px;
    }

    .menu-item.active a {
        background: var(--primary-color);
        color: #fff;
        border: none;
    }

    .menu-text {
        display: block;
    }

    /* Member Management Mobile Overrides */
    .member-container {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 15px;
    }

    .panel-left,
    .panel-right {
        flex: none;
        width: 100%;
        height: auto;
        padding: 15px;
    }

    .member-list-wrapper {
        max-height: 400px;
    }

    .form-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-label {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Global Top Logo */
.top-logo {
    height: 40px;
    width: auto;
    margin-right: 10px;
    vertical-align: middle;
}

/* Scrollable Containers for Tables/Lists to prevent overflow */
.member-list-wrapper,
.log-table-container,
.game-list-container,
.data-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Global Utility Classes */
.desktop-only {
    /* Default visible */
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }
}