/* ==================== CORE INTERFACE COMPONENTS ==================== */

/* Form Fields */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--secondary-color);
    outline: none;
}

/* Photo Upload */
.photo-upload {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
}

.photo-preview {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--secondary-color);
    margin: 10px auto;
    display: block;
}

.upload-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

/* Account Summary Opening Receipt */
.account-summary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 25px;
    border-radius: 15px;
    margin: 20px 0;
    display: none;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.print-btn {
    background: white;
    color: var(--secondary-color);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tables */
.accounts-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: var(--card-bg);
}

.accounts-table th {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    text-align: left;
}

.accounts-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.accounts-table tr:hover {
    background: rgba(52, 152, 219, 0.1);
}

/* OTP Forms */
.otp-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid var(--secondary-color);
}

.otp-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 15px 0;
}

.otp-inputs input {
    width: 40px;
    height: 40px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    transition: all 0.2s;
    outline: none;
    box-shadow: var(--shadow);
}

.otp-inputs input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
    transform: scale(1.05);
}

/* Buttons Styling */
.btn {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #219653);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

/* Header Actions & Notifications */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-action-btn {
    position: relative;
    width: 46px;
    height: 46px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.icon-action-btn:hover {
    transform: translateY(-2px);
    border-color: var(--secondary-color);
}

.notification-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--accent-color);
    color: white;
    font-size: 11px;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
}

.notification-count.has-items {
    display: flex;
}

.notification-preview-btn {
    max-width: 260px;
    min-height: 46px;
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.notification-preview-label {
    font-size: 10px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0;
}

.notification-preview-btn strong {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.25;
    max-width: 230px;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-panel {
    position: fixed;
    top: 112px;
    right: max(16px, calc((100vw - 1400px) / 2 + 180px));
    width: min(430px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 140px));
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 5000;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

[data-theme="dark"] .notification-panel {
    background: #111827;
}

.notification-panel.active {
    display: block;
}

.notification-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.notification-panel-header h3 {
    font-size: 16px;
}

.notification-summary {
    margin-top: 3px;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
}

[data-theme="dark"] .notification-summary {
    color: #cbd5e1;
}

.link-btn {
    border: none;
    background: transparent;
    color: var(--secondary-color);
    cursor: pointer;
    font-weight: 700;
}

.notification-list {
    max-height: min(520px, calc(100vh - 220px));
    overflow-y: auto;
    background: #ffffff;
    min-height: 150px;
    padding: 8px;
}

[data-theme="dark"] .notification-list {
    background: #111827;
}

.notification-item {
    position: relative;
    display: block;
    margin-bottom: 8px;
    padding: 15px 16px;
    border: 1px solid var(--border-color);
    border-left-width: 4px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .notification-item {
    background: rgba(17, 24, 39, 0.96);
}

.notification-item:last-child {
    margin-bottom: 0;
}

.notification-success {
    border-left-color: var(--success-color);
}

.notification-error {
    border-left-color: var(--accent-color);
}

.notification-warning {
    border-left-color: var(--warning-color);
}

.notification-info {
    border-left-color: var(--secondary-color);
}

.notification-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.notification-type-badge {
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--secondary-color);
    font-size: 11px;
    font-weight: 800;
}

.notification-success .notification-type-badge {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-color);
}

.notification-error .notification-type-badge {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-color);
}

.notification-warning .notification-type-badge {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning-color);
}

.notification-title {
    display: block;
    margin-bottom: 6px;
    color: var(--text-color);
    font-size: 15px;
}

.notification-message {
    font-size: 14px;
    color: #334155;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

[data-theme="dark"] .notification-message {
    color: #cbd5e1;
}

.notification-time,
.audit-time {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #94a3b8;
}

.empty-state {
    padding: 18px;
    color: #64748b;
    text-align: center;
}

.audit-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.toast-container {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(380px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2500;
    pointer-events: none;
}

.toast-message {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--secondary-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    animation: toastSlideIn 0.25s ease-out;
    pointer-events: auto;
}

.toast-success {
    border-left-color: var(--success-color);
}

.toast-error {
    border-left-color: var(--accent-color);
}

.toast-warning {
    border-left-color: var(--warning-color);
}

.toast-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.12);
    color: var(--secondary-color);
}

.toast-success .toast-icon {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success-color);
}

.toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-color);
}

.toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning-color);
}

.toast-content strong {
    display: block;
    margin-bottom: 3px;
}

.toast-content p {
    font-size: 13px;
    line-height: 1.4;
    color: #64748b;
}

[data-theme="dark"] .toast-content p {
    color: #cbd5e1;
}

.toast-close {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.toast-close:hover {
    background: rgba(100, 116, 139, 0.12);
    color: var(--accent-color);
}

.toast-leaving {
    opacity: 0;
    transform: translateX(16px);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Messages & Alerts */
.message {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-weight: 500;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.message-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Loader Overlay */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Modals System styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1500;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeInModal 0.25s ease-out;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    margin: auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--secondary-color);
}

.close-modal {
    color: #64748b;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: var(--accent-color);
}

.modal-body {
    padding-top: 10px;
}

/* ==================== ADMIN PORTAL UX POLISH ==================== */

.section > h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    margin-bottom: 24px;
    padding: 18px 20px;
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--secondary-color);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(16, 185, 129, 0.06));
    box-shadow: var(--shadow);
    color: var(--text-color);
}

.section > h2 i {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--secondary-color);
    color: white;
    font-size: 17px;
}

#create.section.active,
#deposit.section.active,
#withdraw.section.active,
#transfer.section.active {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 18px;
    align-items: start;
}

#create.section.active > h2,
#deposit.section.active > h2,
#withdraw.section.active > h2,
#transfer.section.active > h2,
#create .photo-upload,
#create .account-summary,
#create #createResult,
#deposit #depositResult,
#withdraw #withdrawResult,
#transfer #otpSection,
#transfer #transferResult {
    grid-column: 1 / -1;
}

#create .form-group:has(#createAddress),
#transfer .form-group:has(#transferRemarks),
#withdraw .form-group:has(#withdrawPurpose) {
    grid-column: 1 / -1;
}

#create.section.active > .form-group,
#deposit.section.active > .form-group,
#withdraw.section.active > .form-group,
#transfer.section.active > .form-group {
    margin-bottom: 0;
}

#create.section.active > .form-group,
#deposit.section.active > .form-group,
#withdraw.section.active > .form-group,
#transfer.section.active > .form-group,
#search.section.active > .form-group,
.report-controls,
.search-results,
.table-container,
#reportSummaryStats,
.chart-container,
.photo-upload {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

#create.section.active > .form-group,
#deposit.section.active > .form-group,
#withdraw.section.active > .form-group,
#transfer.section.active > .form-group,
#search.section.active > .form-group {
    padding: 16px;
}

#createAddress,
#transferRemarks,
#withdrawPurpose {
    min-height: 48px;
}

#create.section.active > button,
#deposit.section.active > button,
#withdraw.section.active > button,
#transfer.section.active > button {
    width: fit-content;
    min-width: 190px;
    justify-content: center;
}

#withdraw.section.active > button,
#transfer.section.active > button {
    align-self: end;
}

#search.section.active {
    max-width: 900px;
}

#search.section.active > .form-group {
    padding: 20px;
}

#accounts .form-group,
#reports .report-controls {
    margin-bottom: 20px;
}

#accounts .form-group > div,
#search .form-group > div {
    align-items: stretch;
}

#accountsSearch,
#accountsStatusFilter,
#searchAccInput,
#quickSearch {
    min-height: 48px;
}

.table-container {
    overflow: auto;
    padding: 6px;
}

.accounts-table {
    overflow: hidden;
    border-radius: 10px;
}

.accounts-table th:first-child {
    border-top-left-radius: 10px;
}

.accounts-table th:last-child {
    border-top-right-radius: 10px;
}

.accounts-table td,
.accounts-table th {
    white-space: nowrap;
}

.accounts-table tbody tr {
    transition: background 0.2s ease, transform 0.2s ease;
}

.accounts-table tbody tr:hover {
    transform: translateX(2px);
}

#dashboardContent .dashboard-grid > div,
#reportContainer > div,
.search-results {
    border-radius: 12px !important;
    box-shadow: var(--shadow);
}

.search-results {
    padding: 22px;
    margin-top: 20px;
}

.search-results h3,
.search-results h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--secondary-color);
}

#loanApprovals .table-container,
#accounts .table-container,
#reports .table-container {
    margin-top: 16px;
}

#reports .report-controls {
    display: grid !important;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto !important;
    align-items: end;
    gap: 16px !important;
    padding: 18px !important;
}

#reportContainer > div:first-child {
    padding: 16px 18px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 12px;
}

#reportContainer > div:nth-child(2) {
    grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.4fr) !important;
}

#support .search-results {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(236, 253, 245, 0.8));
}

[data-theme="dark"] #support .search-results {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(20, 83, 45, 0.22));
}

#support .search-results > div {
    gap: 18px !important;
}

#support .search-results > div > div {
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
}

[data-theme="dark"] #support .search-results > div > div {
    background: rgba(15, 23, 42, 0.35);
}

.btn:focus-visible,
.menu-item:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    #create.section.active,
    #deposit.section.active,
    #withdraw.section.active,
    #transfer.section.active,
    #reports .report-controls,
    #reportContainer > div:nth-child(2),
    #support .search-results > div {
        grid-template-columns: 1fr !important;
    }

    #create.section.active > button,
    #deposit.section.active > button,
    #withdraw.section.active > button,
    #transfer.section.active > button,
    #accounts .btn,
    #search .btn,
    #reports .btn {
        width: 100%;
    }

    #accounts .form-group > div,
    #search .form-group > div {
        flex-direction: column;
    }

    #accountsStatusFilter {
        max-width: none !important;
    }
}

@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    .header {
        align-items: flex-start;
        gap: 14px;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .notification-wrapper {
        flex: 1;
    }

    .notification-preview-btn {
        flex: 1;
        max-width: none;
    }

    .notification-preview-btn strong {
        max-width: calc(100vw - 150px);
    }

    .theme-toggle {
        flex: 1;
        justify-content: center;
    }

    .notification-panel {
        top: 118px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    .toast-container {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
    }

    .auth-card,
    .content-area {
        padding: 20px;
    }

    .modal-content {
        padding: 20px;
    }

.summary-header,
.modal-header {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
}
}

.loan-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.loan-summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.loan-summary-card span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.loan-summary-card strong {
    color: var(--text-color);
    font-size: 20px;
}

.loan-progress {
    width: 100%;
    min-width: 90px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}

.loan-progress span {
    display: block;
    height: 100%;
    background: var(--success-color);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-width: 72px;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    background: #e2e8f0;
    color: #334155;
}

.status-active,
.status-approved {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
}

.status-pending {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}

.status-rejected {
    background: rgba(239, 68, 68, 0.14);
    color: #b91c1c;
}

.status-closed {
    background: rgba(37, 99, 235, 0.14);
    color: #1d4ed8;
}
