/* Fonts */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

/* CSS Variables */
:root {
    --bg-primary: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F9F9F9;
    
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-tertiary: #8E8E93;
    
    --border-color: #C6C6C8;
    --separator-color: #E5E5EA;
    
    --blue: #007AFF;
    --green: #34C759;
    --orange: #FF9500;
    --red: #FF3B30;
    --purple: #AF52DE;
    --yellow: #FFCC00;
    --pink: #FF2D92;
    --cyan: #5AC8FA;
    
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.15);
    
    --border-radius: 12px;
    --border-radius-large: 16px;
    
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: rgba(255, 255, 255, 0.1);
    --bg-tertiary: rgba(255, 255, 255, 0.05);
    
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);
    
    --border-color: rgba(255, 255, 255, 0.2);
    --separator-color: rgba(255, 255, 255, 0.1);
    
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-primary);
}

.content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
}


/* ===== HEADER / BACK BUTTON ===== */
        .top-nav {
            position: sticky;
            top: 0;
            z-index: 100;
            background: var(--bg);
            border-bottom: 1px solid rgba(128,128,128,0.15);
            padding: 12px 16px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .back-btn {
            display: flex;
            align-items: center;
            gap: 5px;
            color: var(--orange);
            text-decoration: none;
            font-size: 15px;
            font-weight: 600;
            padding: 6px 10px;
            border-radius: 8px;
            transition: background 0.2s;
        }

        .back-btn:hover {
            background: rgba(255,149,0,0.12);
        }

        .back-btn svg {
            width: 18px;
            height: 18px;
        }

        .top-nav-title {
            font-size: 16px;
            font-weight: 700;
            color: var(--text-primary);
            flex: 1;
            text-align: center;
        }
        
/* Header Section */
.header-section {
    background: linear-gradient(135deg, 
        rgba(255, 149, 0, 0.3) 0%, 
        rgba(255, 204, 0, 0.2) 100%);
    border-radius: var(--border-radius-large);
    padding: 20px;
}

.header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.header-text h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.header-text p {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.help-btn {
    background: none;
    border: none;
    color: var(--orange);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover {
    background: rgba(255, 149, 0, 0.1);
    transform: scale(1.05);
}

/* Card Styles */
.card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-large);
    padding: 20px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--separator-color);
}

/* Section Title */
.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.section-title svg {
    color: var(--text-secondary);
}

/* Calculation Type */
.calculation-type-buttons {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 4px;
    margin-bottom: 12px;
}

.type-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: calc(var(--border-radius) - 4px);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.type-btn.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-light);
}

.type-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

.calculation-description {
    padding: 0 4px;
}

.calculation-description p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Input Styles */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group.full-width {
    width: 100%;
}

.input-row {
    display: flex;
    gap: 12px;
}

.input-group.days-input {
    min-width: 120px;
}

.input-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 16px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(0, 122, 255, 0.05) 100%);
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
}

.input-wrapper input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
}

.input-suffix {
    font-size: 12px;
    font-weight: 500;
    margin-right: 8px;
    white-space: nowrap;
}

.input-suffix.green { color: var(--green); }
.input-suffix.orange { color: var(--orange); }
.input-suffix.blue { color: var(--blue); }
.input-suffix.purple { color: var(--purple); }

/* Input Focus Colors */
.input-group:has(.input-wrapper:focus-within) .input-label svg {
    color: var(--blue);
    transform: scale(1.1);
}

/* Calculate Button */
.calculate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 18px 20px;
    background: linear-gradient(135deg, var(--orange) 0%, rgba(255, 204, 0, 0.8) 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 20px rgba(255, 149, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(255, 149, 0, 0.5);
}

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

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

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

/* Results Section */
.results-section {
    background: linear-gradient(135deg, 
        rgba(52, 199, 89, 0.05) 0%, 
        rgba(52, 199, 89, 0.02) 100%);
    border: 1px solid rgba(52, 199, 89, 0.3);
    border-radius: var(--border-radius-large);
    padding: 20px;
    animation: slideUp 0.5s ease-out;
}

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

.results-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.results-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--separator-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.result-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.result-item:nth-child(1) {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.1) 0%, rgba(52, 199, 89, 0.05) 100%);
    border-color: rgba(52, 199, 89, 0.2);
}

.result-item:nth-child(2) {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.1) 0%, rgba(255, 149, 0, 0.05) 100%);
    border-color: rgba(255, 149, 0, 0.2);
}

.result-item:nth-child(4) {
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.1) 0%, rgba(255, 204, 0, 0.05) 100%);
    border-color: rgba(255, 204, 0, 0.2);
}

.result-item:nth-child(5) {
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.1) 0%, rgba(0, 122, 255, 0.05) 100%);
    border-color: rgba(0, 122, 255, 0.2);
}

.result-item:nth-child(6) {
    background: linear-gradient(135deg, rgba(90, 200, 250, 0.1) 0%, rgba(90, 200, 250, 0.05) 100%);
    border-color: rgba(90, 200, 250, 0.2);
}

.result-item:nth-child(7) {
    background: linear-gradient(135deg, rgba(175, 82, 222, 0.1) 0%, rgba(175, 82, 222, 0.05) 100%);
    border-color: rgba(175, 82, 222, 0.2);
}

.result-item.highlighted {
    background: linear-gradient(135deg, rgba(255, 149, 0, 0.2) 0%, rgba(255, 149, 0, 0.1) 100%);
    border: 2px solid var(--orange);
    transform: scale(1.02);
}

.result-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.result-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    direction: rtl;
}

.result-value.highlighted {
    font-size: 18px;
    color: var(--orange);
}

/* Divider */
.divider {
    height: 1px;
    background: var(--separator-color);
    margin: 8px 0;
    opacity: 0.6;
}

/* Share Section */
.share-section {
    margin-top: 16px;
}

.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: none;
    border: 1px solid var(--orange);
    border-radius: var(--border-radius);
    color: var(--orange);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.share-btn:hover {
    background: rgba(255, 149, 0, 0.1);
    transform: translateY(-1px);
}

/* Note Section */
.note-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
}

.note-section span {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Help Sheet */
.help-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.help-sheet.show {
    opacity: 1;
    visibility: visible;
}

.help-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-large);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-medium);
    animation: modalSlide 0.3s ease-out;
}

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

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--separator-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-large) var(--border-radius-large) 0 0;
}

.help-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition);
}

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

.help-body {
    padding: 20px;
}

.help-section {
    margin-bottom: 24px;
}

.help-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.help-section-title.orange { color: var(--orange); }
.help-section-title.blue { color: var(--blue); }
.help-section-title.yellow { color: var(--yellow); }

.help-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.help-card {
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    border: 1px solid var(--separator-color);
}

.help-card.green {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.1) 0%, rgba(52, 199, 89, 0.05) 100%);
    border-color: rgba(52, 199, 89, 0.2);
}

.help-card.purple {
    background: linear-gradient(135deg, rgba(175, 82, 222, 0.1) 0%, rgba(175, 82, 222, 0.05) 100%);
    border-color: rgba(175, 82, 222, 0.2);
}

.help-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.help-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.formula-item {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--separator-color);
}

.formula-item strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.formula-item code {
    font-family: 'Vazirmatn', monospace;
    background: rgba(0, 122, 255, 0.1);
    color: var(--blue);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    display: inline-block;
}

.tips-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tip-item svg {
    margin-top: 2px;
    flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    transition: var(--transition);
    z-index: 100;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Responsive Design */
@media (max-width: 480px) {
    .content {
        padding: 16px;
        gap: 16px;
    }
    
    .input-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .input-group.days-input {
        min-width: unset;
    }
    
    .help-content {
        margin: 10px;
        max-height: 90vh;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Error State */
.input-wrapper.error {
    border-color: var(--red);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, rgba(255, 59, 48, 0.05) 100%);
}

.input-wrapper.error:focus-within {
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1);
}

/* Success Animation */
.success-checkmark {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--green);
    position: relative;
}

.success-checkmark::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Smooth transitions for all interactive elements */
button, .input-wrapper, .result-item, .help-card {
    transition: var(--transition);
}

/* Focus styles for accessibility */
button:focus-visible,
.input-wrapper:focus-within {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}