/* Modern IPL Payment Dashboard */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Modern color palette */
    --primary-bg: #0f172a;
    --secondary-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --accent-primary: #0ea5e9;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

html, body {
    height: 100%;
    font-family: 'Sohne', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--secondary-bg);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-bg) 0%, #1a2942 100%);
    color: #ffffff;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 2.5rem 2rem 1.5rem;
}

.header-title-group h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.header-subtitle {
    font-size: 0.95rem;
    opacity: 0.8;
    font-weight: 400;
    letter-spacing: 0.3px;
    margin: 0;
}

.header-footer {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.last-updated {
    font-size: 0.85rem;
    opacity: 0.75;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #0284c7 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.65rem 1.3rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Sohne', sans-serif;
    position: relative;
    overflow: hidden;
}

.btn-refresh::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-refresh:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    box-shadow: 0 8px 16px rgba(2, 132, 199, 0.4);
    transform: translateY(-2px);
}

.btn-refresh:hover::before {
    left: 100%;
}

.btn-refresh:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-refresh:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.refresh-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-refresh:hover .refresh-icon {
    animation: spin 0.6s linear;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Search Section */
.search-section {
    margin-bottom: 2rem;
}

.search-input {
    width: 100%;
    max-width: 500px;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Sohne', sans-serif;
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.search-input::placeholder {
    color: var(--text-light);
}

/* Error Container */
.error-container {
    background-color: #fecaca;
    color: #991b1b;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border-left: 4px solid var(--accent-danger);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Result Info */
.result-info {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Table Container */
.table-container-scroll {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    position: relative;
    border: 1px solid var(--border-color);
}

.payment-table-compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 100%;
}

.payment-table-compact thead {
    background-color: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.payment-table-compact th {
    padding: 0.75rem 0.6rem;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    border-right: 1px solid var(--border-color);
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

.payment-table-compact td {
    padding: 0.65rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    white-space: nowrap;
    border-right: 1px solid var(--border-color);
}

/* Sticky columns — must override any position on th/td */
.sticky-col {
    position: sticky !important;
    background-color: #f1f5f9;
    z-index: 15;
    font-weight: 500;
}

.payment-table-compact tbody td.sticky-col {
    position: sticky !important;
    background-color: var(--card-bg);
    z-index: 14;
}

.sticky-col-1 {
    left: 0;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    text-align: center;
    overflow: hidden;
}

.sticky-col-2 {
    left: 40px;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    text-align: left;
    font-size: 0.8rem;
    overflow: hidden;
}

.sticky-col-3 {
    left: 130px;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    text-align: left;
    font-size: 0.8rem;
    overflow: hidden;
}

/* Remove internal borders between sticky columns — they form one unified frozen pane */
.payment-table-compact th.sticky-col-1,
.payment-table-compact th.sticky-col-2,
.payment-table-compact tbody td:nth-child(1),
.payment-table-compact tbody td:nth-child(2) {
    border-right: none;
}

/* Right-edge border + shadow on last sticky column to separate from scrollable months */
.payment-table-compact th.sticky-col-3,
.payment-table-compact tbody td:nth-child(3) {
    border-right: 2px solid var(--border-color);
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.08);
}

/* Sticky column styles for data rows — widths must match the th sticky-col widths exactly */
.payment-table-compact tbody td:nth-child(1) {
    position: sticky;
    left: 0;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    background-color: var(--card-bg);
    z-index: 14;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    overflow: hidden;
}

.payment-table-compact tbody td:nth-child(2) {
    position: sticky;
    left: 40px;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    background-color: var(--card-bg);
    z-index: 14;
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
}

.payment-table-compact tbody td:nth-child(3) {
    position: sticky;
    left: 130px;
    width: 130px;
    min-width: 130px;
    max-width: 130px;
    background-color: var(--card-bg);
    z-index: 14;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
}

/* Row hover effect */
.payment-table-compact tbody tr {
    transition: background-color 0.15s ease;
}

.payment-table-compact tbody tr:hover {
    background-color: #f8fafc;
}

.payment-table-compact tbody tr:hover td:nth-child(1),
.payment-table-compact tbody tr:hover td:nth-child(2),
.payment-table-compact tbody tr:hover td:nth-child(3) {
    background-color: #f8fafc;
}

.payment-table-compact tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.status-paid {
    background-color: #dcfce7;
    color: #15803d;
}

.status-paid:hover {
    background-color: #bbf7d0;
}

.status-unpaid {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-unpaid:hover {
    background-color: #fecaca;
}

.status-unknown {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Footer */
.footer {
    background-color: var(--primary-bg);
    color: #cbd5e1;
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .header-content {
        padding: 2rem 2rem 1rem;
    }

    .header-footer {
        padding: 1rem 2rem;
    }

    .header-title-group h1 {
        font-size: 1.5rem;
    }

    .header-subtitle {
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 1.5rem 1rem 1rem;
    }

    .header-footer {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .header-title-group h1 {
        font-size: 1.25rem;
        word-break: break-word;
    }

    .header-subtitle {
        font-size: 0.8rem;
    }

    .main-content {
        padding: 1rem;
    }

    .search-input {
        max-width: 100%;
    }

    .payment-table-compact th,
    .payment-table-compact td {
        padding: 0.5rem 0.4rem;
        font-size: 0.75rem;
    }

    .sticky-col-1 {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
    }

    .sticky-col-2 {
        left: 36px;
        width: 80px;
        min-width: 80px;
        max-width: 80px;
    }

    .sticky-col-3 {
        left: 116px;
        width: 110px;
        min-width: 110px;
        max-width: 110px;
    }

    .payment-table-compact tbody td:nth-child(1) {
        width: 36px;
        min-width: 36px;
        max-width: 36px;
    }

    .payment-table-compact tbody td:nth-child(2) {
        left: 36px;
        width: 80px;
        min-width: 80px;
        max-width: 80px;
    }

    .payment-table-compact tbody td:nth-child(3) {
        left: 116px;
        width: 110px;
        min-width: 110px;
        max-width: 110px;
    }

    .status-badge {
        width: 24px;
        height: 24px;
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0.75rem 0.6rem 0.6rem;
    }

    .header-footer {
        padding: 0.8rem 0.6rem;
        gap: 0.8rem;
    }

    .header-title-group h1 {
        font-size: 1rem;
        margin-bottom: 0.2rem;
        word-break: break-word;
        line-height: 1.1;
    }

    .header-subtitle {
        font-size: 0.7rem;
        opacity: 0.85;
    }

    .last-updated {
        font-size: 0.7rem;
        opacity: 0.7;
    }

    .btn-refresh {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        gap: 0.4rem;
    }

    .refresh-icon {
        width: 14px;
        height: 14px;
    }

    .main-content {
        padding: 0.75rem;
    }

    .search-input {
        padding: 0.7rem 0.8rem;
        font-size: 0.85rem;
    }

    .result-info {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }

    /* Very compact table for mobile */
    .payment-table-compact {
        font-size: 0.7rem;
    }

    .payment-table-compact th {
        padding: 0.4rem 0.25rem;
        font-size: 0.7rem;
        min-width: 32px;
    }

    .payment-table-compact td {
        padding: 0.3rem 0.2rem;
        font-size: 0.7rem;
        min-width: 32px;
    }

    /* Reduce sticky column widths significantly on mobile */
    .sticky-col-1 {
        width: 28px;
        min-width: 28px;
        max-width: 28px;
        padding: 0.3rem 0.15rem;
        font-size: 0.65rem;
    }

    .sticky-col-2 {
        left: 28px;
        width: 54px;
        min-width: 54px;
        max-width: 54px;
        padding: 0.3rem 0.15rem;
        font-size: 0.65rem;
    }

    .sticky-col-3 {
        left: 82px;
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        padding: 0.3rem 0.15rem;
        font-size: 0.65rem;
    }

    .payment-table-compact tbody td:nth-child(1) {
        left: 0;
        width: 28px;
        min-width: 28px;
        max-width: 28px;
        padding: 0.3rem 0.15rem;
        font-size: 0.65rem;
    }

    .payment-table-compact tbody td:nth-child(2) {
        left: 28px;
        width: 54px;
        min-width: 54px;
        max-width: 54px;
        padding: 0.3rem 0.15rem;
        font-size: 0.6rem;
    }

    .payment-table-compact tbody td:nth-child(3) {
        left: 82px;
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        padding: 0.3rem 0.15rem;
        font-size: 0.6rem;
    }

    .status-badge {
        width: 20px;
        height: 20px;
        font-size: 0.55rem;
    }
}
