/* Premium Modern Cooperative Design System CSS (Member & Admin) */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 68px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
}

body {
    font-family: var(--font-family);
    background-color: var(--body-bg);
    color: var(--text-main);
    min-height: 100vh;
    margin: 0;
}

/* App / Admin Wrapper Layout */
.app-wrapper, .admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar, .admin-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    position: relative;
}

/* Collapsed sidebar — icon-only mode */
.app-sidebar.collapsed, .admin-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-nav .nav-link span,
.app-sidebar.collapsed .sidebar-nav .badge,
.app-sidebar.collapsed .sidebar-nav button span,
.admin-sidebar.collapsed .sidebar-brand-text,
.admin-sidebar.collapsed .sidebar-nav .nav-link span,
.admin-sidebar.collapsed .sidebar-nav .badge,
.admin-sidebar.collapsed .sidebar-nav button span {
    opacity: 0;
    width: 0;
    min-width: 0;
    max-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.28s ease;
    pointer-events: none;
}

.app-sidebar.collapsed .sidebar-brand,
.admin-sidebar.collapsed .sidebar-brand {
    padding: 1.25rem 0;
    justify-content: center;
    gap: 0;
}

.app-sidebar.collapsed .sidebar-brand .stat-icon-wrapper,
.admin-sidebar.collapsed .sidebar-brand .stat-icon-wrapper {
    margin: 0 auto;
    flex-shrink: 0;
}

.app-sidebar.collapsed .sidebar-nav .nav-link,
.admin-sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}

.app-sidebar.collapsed .sidebar-nav .nav-link i,
.admin-sidebar.collapsed .sidebar-nav .nav-link i {
    font-size: 1.25rem;
    margin: 0 auto;
    width: auto;
}

.sidebar-toggle-btn {
    position: absolute;
    top: 1.1rem;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    transition: transform 0.25s ease, background-color 0.2s ease;
    font-size: 0.75rem;
}

.sidebar-toggle-btn:hover {
    background: #1d4ed8;
    transform: scale(1.1);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    list-style: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
}

.sidebar-nav .nav-link {
    color: #94a3b8;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
    color: #ffffff;
    background-color: var(--sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #ffffff;
    background-color: var(--sidebar-active);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Main Content Area */
.app-main, .admin-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-color: var(--body-bg);
    min-width: 0;
}

.app-header, .admin-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-content, .admin-content {
    padding: 2rem;
    flex-grow: 1;
}

/* Glassmorphism & Cards */
.stat-widget {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

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

.icon-blue { background: #dbeafe; color: #2563eb; }
.icon-green { background: #d1fae5; color: #10b981; }
.icon-amber { background: #fef3c7; color: #d97706; }
.icon-cyan { background: #cffaff; color: #0891b2; }

/* Member Stat Card gradient */
.stat-card-gradient {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.35);
}

.card-custom {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

/* Custom Tables */
.card-table {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

.table > :not(caption) > * > * {
    padding: 1rem 1.25rem;
    vertical-align: middle;
}

.table thead th {
    background-color: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid var(--border-color);
}

.badge-deposit {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-withdrawal {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Modals & Backdrop */
.custom-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 540px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.btn-xs {
    padding: 0.22rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.25;
    border-radius: 0.35rem;
    font-weight: 500;
}

/* Sidebar Backdrop Overlay on Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 768px) {
    .app-sidebar, .admin-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        width: 270px !important;
        max-width: 85vw !important;
        z-index: 1050 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25) !important;
        overflow-y: auto !important;
    }

    .app-sidebar.mobile-open, .admin-sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    /* On mobile, collapse toggle is hidden; hamburger is used instead */
    .sidebar-toggle-btn {
        display: none !important;
    }

    /* Reset icon-only collapse rules inside mobile drawer */
    .app-sidebar.collapsed .sidebar-brand-text,
    .app-sidebar.collapsed .sidebar-nav .nav-link span,
    .app-sidebar.collapsed .sidebar-nav .badge,
    .app-sidebar.collapsed .sidebar-nav button span,
    .admin-sidebar.collapsed .sidebar-brand-text,
    .admin-sidebar.collapsed .sidebar-nav .nav-link span,
    .admin-sidebar.collapsed .sidebar-nav .badge,
    .admin-sidebar.collapsed .sidebar-nav button span {
        opacity: 1 !important;
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        overflow: visible !important;
        pointer-events: auto !important;
    }

    .app-sidebar.collapsed .sidebar-brand,
    .admin-sidebar.collapsed .sidebar-brand {
        padding: 1.25rem !important;
        justify-content: flex-start !important;
        gap: 0.75rem !important;
    }

    .app-sidebar.collapsed .sidebar-nav .nav-link,
    .admin-sidebar.collapsed .sidebar-nav .nav-link {
        justify-content: flex-start !important;
        padding: 0.75rem 1rem !important;
        gap: 0.85rem !important;
    }

    .app-sidebar.collapsed .sidebar-nav .nav-link i,
    .admin-sidebar.collapsed .sidebar-nav .nav-link i {
        font-size: 1.1rem !important;
        margin: 0 !important;
        width: 20px !important;
    }

    /* Header & Main Padding on Mobile */
    .app-header, .admin-header {
        padding: 0.75rem 1rem !important;
        position: sticky;
        top: 0;
        z-index: 1020;
    }

    .app-content, .admin-content {
        padding: 1rem 0.75rem !important;
    }

    .stat-widget {
        padding: 1rem !important;
    }

    .custom-modal-dialog {
        padding: 1.25rem !important;
        margin: 0.75rem !important;
        max-width: calc(100vw - 1.5rem) !important;
    }

    .admin-mobile-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        min-height: 36px;
    }
}

@media (min-width: 769px) {
    .admin-mobile-toggle {
        display: none !important;
    }
}

[x-cloak] { display: none !important; }
