/* ===========================
   RESET & GLOBAL STYLES
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4CAF50;
    --secondary-color: #FFC107;
    --accent-color: #FF9800;
    --bg-color: #F5F5F5;
    --card-bg: #FFFFFF;
    --text-dark: #212121;
    --text-light: #757575;
    --border-color: #E0E0E0;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --error-color: #F44336;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #E8F5E9 0%, #FFF9C4 100%);
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===========================
   SCREEN MANAGEMENT
   =========================== */
.screen {
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ===========================
   LOGIN SCREEN
   =========================== */
#loginScreen {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-hover);
    text-align: center;
    max-width: 400px;
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.logo {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    animation: bounce 2s infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    background: transparent;
    border-radius: 8px;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.login-card h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 28px;
}

.login-card p {
    color: var(--text-light);
    margin-bottom: 20px;
}

.login-card input {
    width: 100%;
    padding: 15px;
    font-size: 24px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 20px;
    letter-spacing: 10px;
    transition: border-color 0.3s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 10px;
}

/* ===========================
   HEADER
   =========================== */
header {
    background: linear-gradient(135deg, var(--primary-color), #66BB6A);
    color: white;
    padding: 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    background: transparent;
    border-radius: 4px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

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

/* ===========================
   MAIN APP CONTAINER
   =========================== */
#mainApp {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===========================
   CARDS
   =========================== */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    animation: slideUp 0.5s ease;
}

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

.card h2, .card h3 {
    margin-bottom: 20px;
    color: var(--text-dark);
}

.card h2 {
    font-size: 22px;
}

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

/* ===========================
   DASHBOARD STATS
   =========================== */
.dashboard h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.card-today {
    border-left: 5px solid var(--primary-color);
}

.card-month {
    border-left: 5px solid var(--secondary-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 12px;
    transition: background 0.3s;
}

.stat-item:hover {
    background: #E8F5E9;
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-highlight {
    color: var(--primary-color);
    font-size: 26px;
}

/* ===========================
   FORM STYLES
   =========================== */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.calculation-preview {
    background: #E8F5E9;
    padding: 16px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid var(--primary-color);
}

.calculation-preview h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.calculation-preview p {
    margin: 8px 0;
    font-size: 15px;
}

.calculation-preview strong {
    color: var(--primary-color);
    font-size: 16px;
}

/* ===========================
   BUTTONS
   =========================== */
button {
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #66BB6A);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.3s;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-large {
    padding: 18px 36px;
    font-size: 18px;
    margin-top: 10px;
}

.btn-sheets {
    background: linear-gradient(135deg, #34A853, #0F9D58);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    max-width: 400px;
    display: block;
    margin: 0 auto 20px;
    box-shadow: 0 4px 12px rgba(52, 168, 83, 0.3);
    transition: transform 0.2s, box-shadow 0.3s;
}

.btn-sheets:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(52, 168, 83, 0.4);
}

/* ===========================
   NOTIFICATIONS
   =========================== */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    padding: 16px 24px;
    border-radius: 10px;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    animation: slideInRight 0.3s ease;
    max-width: 350px;
    border-left: 4px solid var(--success-color);
}

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

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

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

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

/* ===========================
   OFFLINE INDICATOR
   =========================== */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning-color);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* ===========================
   ANIMATIONS
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */
@media (max-width: 768px) {
    header h1 {
        font-size: 16px;
        gap: 10px;
    }

    .header-logo {
        width: 42px;
        height: 42px;
    }

    .logo-img {
        width: 150px;
        height: 150px;
    }

    .install-logo-img {
        width: 90px;
        height: 90px;
    }

    .btn-logout {
        padding: 6px 12px;
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-highlight {
        font-size: 22px;
    }

    .card {
        padding: 16px;
    }

    #mainApp {
        padding: 12px;
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .login-card {
        padding: 30px 20px;
    }

    .header-actions {
        gap: 6px;
    }

    .btn-install-header {
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .btn-large {
        font-size: 16px;
        padding: 16px 24px;
    }

    header h1 {
        font-size: 14px;
        gap: 8px;
    }

    .header-logo {
        width: 38px;
        height: 38px;
    }

    .logo-img {
        width: 130px;
        height: 130px;
    }

    .install-logo-img {
        width: 80px;
        height: 80px;
    }
}

/* ===========================
   PWA SPECIFIC
   =========================== */
@media (display-mode: standalone) {
    body {
        -webkit-user-select: none;
        user-select: none;
    }

    header {
        padding-top: max(20px, env(safe-area-inset-top));
    }
}

/* ===========================
   LOADING STATE
   =========================== */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===========================
   INSTALL PWA PROMPT
   =========================== */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 20px;
    z-index: 2000;
    animation: slideUpInstall 0.4s ease;
}

@keyframes slideUpInstall {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-card {
    max-width: 500px;
    margin: 0 auto;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.install-icon {
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.install-logo-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    animation: bounceInstall 2s infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
    background: transparent;
    border-radius: 6px;
}

@keyframes bounceInstall {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.install-card h3 {
    color: var(--primary-color);
    font-size: 22px;
    margin-bottom: 8px;
}

.install-card p {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 15px;
}

.install-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-install {
    background: linear-gradient(135deg, var(--primary-color), #66BB6A);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transition: transform 0.2s, box-shadow 0.3s;
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

.btn-install:active {
    transform: translateY(0);
}

.btn-dismiss {
    background: transparent;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-dismiss:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--text-light);
}

/* Install button in header (alternative) */
.btn-install-header {
    background: linear-gradient(135deg, var(--secondary-color), #FFD54F);
    color: var(--text-dark);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
    transition: transform 0.2s, box-shadow 0.3s;
}

.btn-install-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

@media (max-width: 768px) {
    .install-prompt {
        padding: 16px;
    }

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

    .install-icon {
        font-size: 50px;
    }

    .install-card h3 {
        font-size: 18px;
    }

    .install-card p {
        font-size: 14px;
    }

    .install-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .btn-install,
    .btn-dismiss {
        width: 100%;
    }
}
