/* CSS Variables */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== AUTH OVERLAY STYLES ==================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    overflow-y: auto;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    justify-content: center;

    /* 👇 KEY FIX */
    align-items: flex-start;

    padding: 20px;
}

.auth-card {
    background: #1e293b;
    border-radius: 28px;
    padding: 40px;
    width: 100%;
    max-width: 450px;

    /* 👇 THIS centers it properly without clipping */
    margin: auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header i {
    font-size: 56px;
    color: #3b82f6;
    margin-bottom: 20px;
}

.auth-header h2 {
    color: white;
    margin-bottom: 10px;
    font-size: 28px;
}

.auth-header p {
    color: #94a3b8;
    font-size: 15px;
}

.btn-primary-auth {
    width: 100%;
    padding: 14px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    font-size: 16px;
    transition: all 0.2s;
}

.btn-primary-auth:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.auth-divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #334155;
}

.auth-divider span {
    background: #1e293b;
    padding: 0 12px;
    position: relative;
    color: #94a3b8;
    font-size: 13px;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.google-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
}

.guest-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 12px;
    color: #94a3b8;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.guest-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #3b82f6;
    color: white;
    transform: translateY(-1px);
}

.auth-toggle {
    text-align: center;
    margin-top: 24px;
    color: #94a3b8;
    font-size: 14px;
}

.auth-toggle a {
    color: #3b82f6;
    cursor: pointer;
    text-decoration: none;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.error-message {
    background: #ef444420;
    color: #ef4444;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 20px;
    text-align: center;
}

/* User Info Bar */
.user-info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #1e293b;
    border-radius: 40px;
}

.user-email-display {
    color: white;
    font-size: 13px;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sign-out-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.sign-out-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ==================== MAIN APP STYLES ==================== */
.app {
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 24px;
    padding-bottom: 30px;
    position: relative;
}

/* Header */
.header {
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.title {
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.title i {
    color: var(--accent);
    font-size: 32px;
}

.icon-btn {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.icon-btn:hover {
    background: var(--bg-card);
    transform: translateY(-2px);
}

.icon-btn-small {
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
}

.icon-btn-small:hover {
    background: var(--bg-card);
    transform: translateY(-1px);
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.summary-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.summary-card i {
    font-size: 32px;
    color: var(--accent);
}

.summary-info {
    display: flex;
    flex-direction: column;
}

.summary-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 28px;
    font-weight: 700;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 12px;
    margin: 28px 0 20px;
    flex-wrap: wrap;
}

.filter-tab {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.filter-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 14px 20px;
    margin-bottom: 20px;
}

.search-bar i {
    color: var(--text-secondary);
    font-size: 18px;
}

.search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

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

/* Sort Options */
.sort-options {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sort-options label {
    color: var(--text-secondary);
    font-size: 14px;
}

.sort-options select {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

.sort-options select:hover {
    border-color: var(--accent);
}

/* Subscription List */
.subscription-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 20px;
    min-height: 200px;
}

.subscription-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.2s;
    animation: slideIn 0.3s ease;
}

.subscription-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.card-color {
    width: 10px;
    height: 60px;
    border-radius: 6px;
}

.card-content {
    flex: 1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title h3 {
    font-size: 18px;
    font-weight: 600;
}

.category-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    text-transform: uppercase;
}

.card-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.card-details {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.card-detail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.card-detail i {
    font-size: 13px;
}

/* Urgency Styles */
.card-detail.urgent {
    color: #ef4444 !important;
    font-weight: 600;
}

.card-detail.urgent i {
    color: #ef4444 !important;
    animation: pulse 1s infinite;
}

.card-detail.soon {
    color: #f59e0b !important;
    font-weight: 500;
}

.card-detail.soon i {
    color: #f59e0b !important;
}

.card-detail.overdue {
    color: #dc2626 !important;
    font-weight: 700;
}

.card-detail.overdue i {
    color: #dc2626 !important;
    animation: shake 0.5s ease-in-out;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.status-badge.cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.subscription-card:hover .card-actions {
    opacity: 1;
}

.card-action-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.card-action-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: translateY(-1px);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-state i {
    font-size: 80px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 16px;
}

.empty-state.hidden {
    display: none;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5);
}

/* Footer */
footer {
    text-align: center;
    padding: 32px 24px 40px;
    color: #64748b;
    font-size: 14px;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
}

footer p {
    margin: 10px 0;
}

footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

footer a:hover {
    color: #60a5fa;
    text-decoration: underline;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(8px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    max-width: 550px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    animation: slideUp 0.3s ease;
}

.confirm-modal {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: var(--bg-card);
}

.modal-body {
    padding: 20px 24px 24px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
}

/* Color Options */
.color-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.color-options input[type="radio"] {
    display: none;
}

.color-label {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    display: block;
}

.color-options input[type="radio"]:checked+.color-label {
    border-color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 16px;
    margin-top: 28px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn.primary {
    background: var(--accent);
    color: white;
}

.btn.primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.btn.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    margin-top: 16px;
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: translateY(-1px);
}

.btn.full-width {
    width: 100%;
    margin-bottom: 12px;
}

/* Settings */
.settings-section {
    margin: 28px 0;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.settings-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.danger-zone {
    border-color: var(--danger);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 14px 28px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    z-index: 2000;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: var(--shadow);
    white-space: nowrap;
    font-size: 14px;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-15px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

/* Utility */
.hidden {
    display: none !important;
}

/* ==================== RESPONSIVE DESIGN ==================== */
/* Desktop first - then scale down */
/* Large Desktop */
@media (min-width: 1400px) {
    .app {
        max-width: 1400px;
        padding: 32px;
    }

    .subscription-list {
        grid-template-columns: repeat(auto-fill, minmax(550px, 1fr));
        gap: 24px;
    }
}

/* Standard Desktop */
@media (min-width: 1024px) and (max-width: 1399px) {
    .app {
        max-width: 1100px;
        padding: 28px;
    }

    .subscription-list {
        grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
        gap: 20px;
    }
}

/* Desktop: perfectly centered */
@media (min-height: 700px) {
    .auth-overlay {
        align-items: center;
    }

    .auth-card {
        margin: 0;
    }
}

/* Small screens: safe scrolling */
@media (max-height: 699px) {
    .auth-overlay {
        align-items: flex-start;
    }

    .auth-card {
        margin: auto;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .app {
        max-width: 90%;
        padding: 24px;
    }

    .subscription-list {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .summary-cards {
        gap: 16px;
    }

    .summary-card {
        padding: 20px 16px;
    }

    .summary-value {
        font-size: 24px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .app {
        max-width: 100%;
        padding: 16px;
        padding-bottom: 24px;
    }

    .title {
        font-size: 24px;
    }

    .title i {
        font-size: 24px;
    }

    .summary-cards {
        gap: 10px;
    }

    .summary-card {
        padding: 14px 10px;
    }

    .summary-card i {
        font-size: 20px;
    }

    .summary-value {
        font-size: 18px;
    }

    .summary-label {
        font-size: 11px;
    }

    .fab {
        width: 56px;
        height: 56px;
        bottom: 20px;
        right: 20px;
        font-size: 24px;
    }

    .modal-content {
        max-height: 80vh;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card-actions {
        opacity: 1;
    }

    .toast {
        bottom: 80px;
        white-space: normal;
        text-align: center;
        max-width: 90%;
        padding: 12px 20px;
    }

    .auth-card {
        padding: 28px 24px;
        max-width: 95%;
    }

    .filter-tabs {
        gap: 8px;
    }

    .filter-tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .subscription-list {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-price {
        font-size: 18px;
    }

    .card-details {
        gap: 12px;
    }

    .sort-options {
        justify-content: flex-start;
    }

    .user-email-display {
        max-width: 130px;
        font-size: 11px;
    }

    .user-info-bar {
        gap: 8px;
        padding: 6px 12px;
    }

    .sign-out-btn {
        padding: 4px 10px;
        font-size: 11px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .app {
        padding: 12px;
    }

    .summary-cards {
        gap: 8px;
    }

    .summary-card {
        padding: 12px 8px;
    }

    .summary-card i {
        font-size: 18px;
    }

    .summary-value {
        font-size: 16px;
    }

    .filter-tab {
        padding: 6px 12px;
        font-size: 12px;
    }

    .card-title h3 {
        font-size: 15px;
    }

    .card-price {
        font-size: 16px;
    }

    .user-email-display {
        max-width: 100px;
    }

    .sign-out-btn {
        padding: 4px 8px;
        font-size: 10px;
    }

    .auth-card {
        padding: 24px 20px;
    }

    .auth-header i {
        font-size: 44px;
    }

    .auth-header h2 {
        font-size: 24px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    button,
    .filter-tab,
    .nav-item,
    .card-action-btn {
        cursor: default;
    }

    .subscription-card {
        cursor: pointer;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .app {
        padding: 16px;
    }

    .subscription-list {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }

    .auth-card {
        max-width: 90%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Add to your style.css file - better mobile signup */
@media (max-width: 480px) {
    .sign-up-overlay .auth-card {
        padding: 20px 16px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .sign-up-overlay .form-group input {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 12px !important;
    }

    .sign-up-overlay .btn-primary-auth {
        padding: 12px !important;
        font-size: 16px !important;
    }
}
