/* ==========================================================================
   Community Portal - Enterprise Admin Design System & Modular Stylesheet
   Font: Inter
   Theme: Professional Light Mode
   ========================================================================== */

:root {
    --bg-body: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-topbar: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

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

/* ==========================================================================
   Layout & Sidebar Navigation
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #ffffff;
}

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.sidebar-brand-badge {
    font-size: 0.65rem;
    background: #eff6ff;
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid #bfdbfe;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Custom Sleek Scrollbar for Sidebar */
.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.menu-label {
    font-size: 0.725rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    font-weight: 700;
    padding: 0.85rem 0.85rem 0.35rem 0.85rem;
    margin-top: 0.25rem;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
    color: #475569;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.925rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item a:hover {
    color: #0f172a;
    background: #f1f5f9;
    transform: translateX(3px);
}

.menu-item.active a {
    color: #2563eb;
    background: #eff6ff;
    font-weight: 700;
    box-shadow: inset 3px 0 0 #2563eb;
}

.menu-item i {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    transition: transform 0.2s ease;
}

.menu-item a:hover i {
    transform: scale(1.15);
}

.sidebar-footer {
    padding: 1rem 1.15rem;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.user-info {
    flex-grow: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 64px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.page-content {
    padding: 1.75rem;
    flex-grow: 1;
}

/* ==========================================================================
   Buttons Component System
   ========================================================================== */

.btn {
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    border: none;
    transition: background-color 0.15s ease;
}

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

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

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f1f5f9;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.btn-edit {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.btn-edit:hover {
    background: #dbeafe;
}

.btn-delete {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.btn-delete:hover {
    background: #fee2e2;
}

.btn-logout {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: #ef4444;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.15s ease;
}

.btn-logout:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

.btn-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-submit:hover {
    background: var(--primary-hover);
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Cards & Stats Grid Components
   ========================================================================== */

.card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

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

.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-emerald { background: #ecfdf5; color: #059669; }
.icon-amber { background: #fffbeb; color: #d97706; }
.icon-purple { background: #f5f3ff; color: #7c3aed; }

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

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

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-action:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--primary);
}

.btn-action-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ==========================================================================
   Form Component System & 12-Column Grid
   ========================================================================== */

.grid-container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.25rem;
}

.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

@media (max-width: 992px) {
    .col-8, .col-6, .col-4, .col-3 {
        grid-column: span 12;
    }
}

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

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

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrapper:has(.input-icon) .form-control,
.input-wrapper.has-icon-left .form-control {
    padding-left: 2.5rem;
}

.input-wrapper:has(.toggle-password) .form-control {
    padding-right: 2.5rem;
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.toggle-password {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 0.9rem;
}

.toggle-password:hover {
    color: var(--text-main);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-picker-input {
    width: 44px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    background: #ffffff;
}

.form-error {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.remember-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.custom-checkbox input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ==========================================================================
   Table & Badge Component System
   ========================================================================== */

.table-responsive, .table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    background: #f8fafc;
}

.data-table td {
    font-size: 0.875rem;
    color: #334155;
}

.community-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.color-swatch-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-swatch-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-family: monospace;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.logo-preview-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.current-logo-img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.badge, .badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-inactive {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.pagination-wrapper {
    margin-top: 1.25rem;
}

/* ==========================================================================
   Alerts & Authentication Page Layouts
   ========================================================================== */

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.825rem;
    margin-top: 1.25rem;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.login-page-body {
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.brand-header {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-logo-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #ffffff;
    margin-bottom: 0.85rem;
}

.brand-title {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ==========================================================================
   Enterprise Pagination Controls Styling
   ========================================================================== */

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pagination svg, nav svg {
    width: 1.1rem !important;
    height: 1.1rem !important;
    max-width: 1.1rem !important;
    max-height: 1.1rem !important;
    vertical-align: middle;
}

.page-item .page-link,
.pagination li a,
.pagination li span,
nav[role="navigation"] a,
nav[role="navigation"] span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.page-item.active .page-link,
.pagination li.active span,
.pagination li.active a,
nav[role="navigation"] span[aria-current="page"] span,
nav[role="navigation"] span[aria-current="page"] {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.page-item:not(.active) .page-link:hover,
.pagination li a:hover,
nav[role="navigation"] a:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: #cbd5e1;
}

.page-item.disabled .page-link,
.pagination li.disabled span,
nav[role="navigation"] span[aria-disabled="true"] span {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f8fafc;
}

.footer-note {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1.75rem;
}

/* ==========================================================================
   Mobile Sidebar Toggle Button & Overlay Controls
   ========================================================================== */

.sidebar-toggle-btn {
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ==========================================================================
   Enterprise Responsive Breakpoints (Tablet & Mobile Devices)
   ========================================================================== */

/* Laptops & Tablets (<= 991px) */
@media (max-width: 991px) {
    .sidebar-toggle-btn {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        z-index: 100;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .topbar {
        padding: 0.85rem 1.25rem;
    }

    .page-content {
        padding: 1.25rem;
    }

    /* Stack 2-column sidebar layouts (e.g. Master Settings side nav & content) */
    div[style*="grid-template-columns: 280px 1fr"],
    div[style*="grid-template-columns: 280px"],
    .grid-2col {
        grid-template-columns: 1fr !important;
    }

    /* Keep settings sticky menu non-sticky on mobile */
    div[style*="position: sticky; top: 80px"] {
        position: static !important;
    }
}

/* Mobile Devices & Small Tablets (<= 768px) */
@media (max-width: 768px) {
    .topbar {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0 1rem !important;
        height: 64px !important;
        gap: 0.5rem;
    }

    .topbar-title {
        font-size: 1.05rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .card {
        padding: 1rem !important;
    }

    /* Stack Header Action Bars & Card Headers (Excluding Topbar) */
    .header-actions,
    .card-header-flex,
    .page-header-flex,
    .card > div[style*="justify-content: space-between"]:not(.topbar) {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .header-actions .btn,
    .card-header-flex .btn {
        width: 100%;
        justify-content: center;
    }

    /* Responsive Grid Containers */
    .grid-container,
    div[style*="grid-template-columns: repeat(auto-fill"],
    div[style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr !important;
    }

    /* Smooth Touch Table Horizontally Scrollable Container */
    .table-container,
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .data-table {
        min-width: 650px;
    }

    /* Responsive Modals */
    .modal-content,
    div[style*="max-width: 600px"],
    div[style*="max-width: 550px"] {
        width: 92% !important;
        margin: 1rem auto !important;
        padding: 1.25rem !important;
    }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
    .topbar-actions span {
        display: none;
    }

    .pagination-wrapper {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
    }
}
