/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --currency-green: #006A4E;
    --currency-green-dark: #004d38;
    --primary-color: #006A4E;
    --primary-dark: #004d38;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #d4e5df;
    --border-color: #a8c4b8;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    :root {
        --currency-green: #006A4E;
        --currency-green-dark: #004d38;
        --primary-color: #006A4E;
        --primary-dark: #004d38;
        --success-color: #10b981;
        --warning-color: #fbbf24;
        --error-color: #f87171;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --bg-primary: #374151;
        --bg-secondary: #111827;
        --border-color: #4b5563;
        --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    }

    .status-settled {
        background: #065f46;
        color: #d1fae5;
    }

    .status-pending {
        background: #92400e;
        color: #fef3c7;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Main Content */
main {
    padding: 0 0 2rem 0;
}

/* Page Header */
.page-header {
    background: var(--currency-green);
    color: white;
    padding: 1.25rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-icon {
    width: 48px;
    height: 48px;
    display: block;
    flex-shrink: 0;
    object-fit: contain;
}

.header-text {
    flex: 1;
}

/* Line 1: Matches .merchant-name */
.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
}

/* Line 2: Matches .transaction-meta */
.header-subtitle {
    font-size: 0.875rem;
    font-weight: normal;
    color: white;
    opacity: 0.95;
    margin-bottom: 0.25rem;
}

/* Line 3: Matches .transaction-category */
.header-meta {
    font-size: 0.75rem;
    font-weight: normal;
    color: white;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.header-link:hover {
    text-decoration: none;
}

.why-link {
    color: #F4C430;
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
    cursor: pointer;
}

.why-link:hover {
    opacity: 1;
    text-decoration: none;
}

.update-time-header {
    font-size: 0.875rem;
    opacity: 0.9;
    text-align: left;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

/* Transactions Section */
.transactions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-refresh svg {
    transition: transform 0.3s;
}

.btn-refresh:active svg {
    transform: rotate(180deg);
}

/* Loading State */
.loading {
    background: var(--bg-primary);
    padding: 3rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    text-align: center;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
}

/* Error State */
.error {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    text-align: center;
    color: var(--error-color);
}

/* Transactions List */
.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.transactions-list.hidden {
    display: none;
}

.transaction-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.transaction-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.merchant-logo {
    width: 48px;
    height: 48px;
    border-radius: 0.375rem;
    object-fit: cover;
    background: var(--bg-secondary);
}

.transaction-details {
    flex: 1;
}

.merchant-info {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.merchant-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.transaction-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    font-weight: 600;
}

.status-settled {
    background: #d1fae5;
    color: #065f46;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.transaction-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.transaction-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.transaction-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.transaction-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Load More Button */
.btn-load-more {
    width: 100%;
    padding: 0.75rem;
    background: var(--currency-green);
    color: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-load-more:hover {
    background: var(--currency-green-dark);
    box-shadow: var(--shadow-md);
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem 0;
    font-size: 0.75rem;
}

footer p {
    margin: 0;
    margin-bottom: 0.35rem;
}

footer a {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

footer a:hover {
    text-decoration: none;
}

/* Analytics Notice */
.analytics-notice {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ga-toggle-link {
    text-decoration: none;
}

/* AWS Logo */
.aws-logo-link {
    display: inline-block;
    line-height: 0;
    margin: 0;
    margin-top: 0.7rem;
}

.aws-logo {
    height: 30px;
    width: auto;
    display: block;
    margin: 0;
}

/* Show light logo by default, hide dark logo */
.aws-logo-light {
    display: block;
}

.aws-logo-dark {
    display: none;
}

/* In dark mode, hide light logo and show dark logo */
@media (prefers-color-scheme: dark) {
    .aws-logo-light {
        display: none;
    }

    .aws-logo-dark {
        display: block;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: modal-fade-in 0.2s ease-out;
}

.modal.hidden {
    display: none;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    animation: modal-slide-up 0.2s ease-out;
}

@keyframes modal-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    padding-right: 2rem;
}

.modal-body {
    color: var(--text-primary);
    line-height: 1.7;
}

.modal-body p {
    margin-bottom: 1rem;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Invisible links - only visible on hover */
.modal-invisible-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.modal-invisible-link:hover {
    text-decoration: none;
}

/* Dark mode: use brighter green for better readability */
@media (prefers-color-scheme: dark) {
    .modal-body strong {
        color: var(--success-color);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header-text {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .header-icon {
        width: 48px;
        height: 48px;
        object-fit: contain;
    }

    .btn-refresh {
        align-self: stretch;
        justify-content: center;
    }

    .transaction-card {
        flex-direction: column;
        text-align: center;
    }

    .transaction-details {
        width: 100%;
    }

    .merchant-info {
        justify-content: center;
    }

    .transaction-meta {
        justify-content: center;
        flex-wrap: wrap;
    }

    .transaction-amount {
        font-size: 2rem;
    }
}
