:root {
    --primary: #4361ee;
    --secondary: #3a0ca3;
    --success: #4cc9f0;
    --warning: #f72585;
    --danger: #dc3545;
    --dark: #212529;
    --light: #f8f9fa;
    --sidebar-bg: #ffffff;
    --sidebar-text: #333333;
    --sidebar-hover: #f8f9fa;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fb;
    color: #333;
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR STYLES ===== */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar .logo {
    padding: 30px 20px;
    border-bottom: 1px solid #e9ecef;
    background: var(--primary);
    color: white;
}

.sidebar .logo h1 {
    font-size: 1.5rem;
    margin: 0;
    display: flex;
    align-items: center;
}

.sidebar .logo i {
    margin-right: 10px;
    font-size: 1.3rem;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.nav-links li {
    margin: 0;
}

.nav-links a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-bottom: 1px solid #f8f9fa;
    transition: var(--transition);
    font-weight: 500;
}

.nav-links a:hover {
    background: var(--sidebar-hover);
    color: var(--primary);
    padding-left: 25px;
}

.nav-links a.active {
    background: var(--primary);
    color: white;
    border-left: 4px solid var(--secondary);
}

.nav-links a.active:hover {
    background: var(--secondary);
    color: white;
}

.nav-links i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    text-align: center;
}

.user-section {
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
    font-size: 0.9rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.user-email {
    font-size: 0.8rem;
    color: #6c757d;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 280px;
    transition: var(--transition);
    width: calc(100% - 280px);
    min-height: 100vh;
    background: #f5f7fb;
}

.header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.welcome h2 {
    color: var(--dark);
    margin-bottom: 0.25rem;
    font-size: 1.5rem;
}

.welcome p {
    color: #6c757d;
    margin: 0;
}

/* ===== SUMMARY CARDS ===== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

.card-title {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.icon-monthly { background: var(--primary); }
.icon-yearly { background: var(--success); }
.icon-renewals { background: var(--warning); }
.icon-subscriptions { background: var(--secondary); }

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.card-change {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-change.positive { color: #28a745; }
.card-change.warning { color: #ffc107; }

/* ===== DASHBOARD SECTIONS ===== */
.dashboard-section {
    background: white;
    margin: 1.5rem;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

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

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    font-size: 1.25rem;
    margin: 0;
}

.view-all {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.view-all:hover {
    color: var(--secondary);
    gap: 0.75rem;
}

/* ===== IMPROVED SUBSCRIPTION ITEMS - NO OVERLAPPING ===== */
.subscription-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.subscription-item {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    border-radius: 12px;
    background: var(--light);
    transition: var(--transition);
    border: 1px solid #e9ecef;
    gap: 1rem;
    flex-wrap: wrap;
}

.subscription-item:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.15);
}

.subscription-item.due-soon {
    border-left: 4px solid var(--warning);
    background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
}

.service-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--primary);
}

.service-details {
    flex: 1;
    min-width: 200px;
    overflow: hidden;
}

.service-name {
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.service-info {
    color: #6c757d;
    font-size: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    line-height: 1.4;
}

.category-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    white-space: nowrap;
}

.category-badge.streaming { background: #E50914; color: white; }
.category-badge.software { background: #0366d6; color: white; }
.category-badge.utilities { background: #28a745; color: white; }
.category-badge.gaming { background: #6f42c1; color: white; }
.category-badge.productivity { background: #fd7e14; color: white; }
.category-badge.cloud { background: #17a2b8; color: white; }
.category-badge.music { background: #e83e8c; color: white; }
.category-badge.news { background: #ffc107; color: #000; }
.category-badge.fitness { background: #dc3545; color: white; }
.category-badge.other { background: #6c757d; color: white; }

.service-cost {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--dark);
    margin-left: auto;
    white-space: nowrap;
    min-width: 80px;
    text-align: right;
}

.service-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.action-btn {
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

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

.action-btn.delete {
    background: var(--danger);
    color: white;
}

.action-btn:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

/* ===== MOBILE MENU SYSTEM ===== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    padding: 10px 12px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: var(--transition);
}

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

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

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

.close-sidebar-mobile {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 18px;
    color: white;
    cursor: pointer;
    z-index: 1002;
    padding: 5px;
    border-radius: 4px;
    transition: var(--transition);
}

.close-sidebar-mobile:hover {
    background: rgba(255,255,255,0.1);
}

/* ===== CRITICAL MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        left: -280px !important;
        transition: left 0.3s ease-in-out;
    }
    
    .sidebar.active {
        left: 0 !important;
    }
    
    .close-sidebar-mobile {
        display: block;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 15px;
    }
    
    .header {
        padding-left: 60px;
        padding-top: 10px;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .card-value {
        font-size: 1.5rem;
    }
    
    .dashboard-section {
        margin: 1rem;
        padding: 1.25rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
        margin-bottom: 1.25rem;
    }
    
    .view-all {
        align-self: flex-end;
        font-size: 0.85rem;
    }
    
    /* ===== MOBILE SUBSCRIPTION ITEM FIXES ===== */
    .subscription-item {
        padding: 1rem;
        gap: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .service-icon {
        width: 45px;
        height: 45px;
        font-size: 0.9rem;
    }
    
    .service-details {
        min-width: 100%;
        order: 2;
    }
    
    .service-name {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }
    
    .service-info {
        font-size: 0.8rem;
        gap: 0.4rem;
    }
    
    .category-badge {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }
    
    .service-cost {
        font-size: 1.2rem;
        margin-left: 0;
        order: 1;
        min-width: auto;
        text-align: left;
        width: 100%;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #e9ecef;
    }
    
    .service-actions {
        order: 3;
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
    }
}

/* ===== SMALL MOBILE DEVICES (iPhone SE, etc.) ===== */
@media (max-width: 375px) {
    .main-content {
        padding: 0 10px;
    }
    
    .header {
        padding-left: 50px;
    }
    
    .mobile-menu-btn {
        top: 10px;
        left: 10px;
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .subscription-item {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .service-icon {
        width: 40px;
        height: 40px;
        font-size: 0.8rem;
    }
    
    .service-name {
        font-size: 0.95rem;
    }
    
    .service-info {
        font-size: 0.75rem;
    }
    
    .service-cost {
        font-size: 1.1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .card-value {
        font-size: 1.3rem;
    }
}

/* Hide hamburger menu on desktop */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .close-sidebar-mobile {
        display: none !important;
    }
}

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.empty-state small {
    font-size: 0.9rem;
}

/* ===== FLASH MESSAGES ===== */
.flash-messages {
    margin: 1.5rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* ===== FORM STYLES (For Add/Edit Subscription Pages) ===== */
.form-container {
    background: white;
    margin: 1.5rem;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: var(--secondary);
    transform: translateY(-2px);
}

/* Mobile form improvements */
@media (max-width: 768px) {
    .form-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Personal Welcome Card Styles */
.personal-welcome-card {
    background: linear-gradient(135deg, #4361ee, #3a0ca3);
    color: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

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

.welcome-text h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.welcome-text p {
    margin: 0;
    opacity: 0.9;
    font-size: 1.1rem;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-outline:hover {
    background: white;
    color: #4361ee;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .welcome-content {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .welcome-actions {
        justify-content: center;
    }
}
