:root {
    --primary-color: #006837;
    --primary-light: #00a651;
    --primary-dark: #004d29;
    --accent-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-light: #f8fafc;
    --background-dark: #1f2937;
    --text-light: #1f2937;
    --text-dark: #f3f4f6;
    --border-light: #e5e7eb;
    --border-dark: #374151;
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-dark: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --header-height: 70px;
    --transition-speed: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
    transition: background-color var(--transition-speed) ease, 
                color var(--transition-speed) ease,
                border-color var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text-light);
    background: linear-gradient(120deg, #f0f9f6, #e6f7f2);
    padding-top: var(--header-height);
}

body.dark-mode {
    color: var(--text-dark);
    background: linear-gradient(120deg, #1a2535, #111927);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-light);
}

body.dark-mode ::-webkit-scrollbar-track {
    background: var(--background-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Header Styles */
header {
    background-color: var(--primary-color);
    padding: 0.5rem 0;
    box-shadow: var(--shadow-light);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    height: var(--header-height);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    max-width: 100%;
    margin: 0 auto;
    height: 100%;
}

.header-content > div {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    width: auto;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(5px);
}

/* Side Menu Styles */
.side-menu {
    position: fixed;
    right: -100%;
    top: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--background-light);
    box-shadow: var(--shadow-light);
    transition: right var(--transition-speed) ease;
    z-index: 999;
    overflow-y: auto;
    padding: calc(var(--header-height) + 1rem) 1rem 1rem 1rem;
}

body.dark-mode .side-menu {
    background-color: var(--background-dark);
    box-shadow: var(--shadow-dark);
}

.side-menu.active {
    right: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

body.dark-mode .menu-header {
    border-bottom-color: var(--border-dark);
}

.menu-items {
    list-style: none;
}

.menu-item {
    margin-bottom: 1rem;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    color: var(--text-light);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    border-radius: 0.5rem;
}

body.dark-mode .menu-link {
    color: var(--text-dark);
}

.menu-link:hover {
    background-color: var(--border-light);
}

body.dark-mode .menu-link:hover {
    background-color: var(--border-dark);
}

.menu-link i {
    margin-left: 0.75rem;
    width: 20px;
    text-align: center;
}

.submenu {
    list-style: none;
    margin-right: 2rem;
    margin-top: 0.5rem;
    display: none;
}

.submenu.active {
    display: block;
}

.menu-close {
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.menu-close:hover {
    background-color: var(--primary-light);
    transform: scale(1.1);
}

/* Container - Full Width */
.container {
    max-width: 100%;
    margin: 2rem 0;
    padding: 0 1rem;
}

/* Main Content */
.age-calculator {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 1rem;
    box-shadow: var(--shadow-light);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.dark-mode .age-calculator {
    background-color: rgba(31, 41, 55, 0.8);
    box-shadow: var(--shadow-dark);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

body.dark-mode .calculator-header {
    border-bottom-color: var(--border-dark);
}

.calculator-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

body.dark-mode .calculator-title {
    color: var(--primary-light);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-light);
    background-color: var(--border-light);
    transition: all var(--transition-speed) ease;
}

body.dark-mode .theme-toggle {
    color: var(--text-dark);
    background-color: var(--border-dark);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.date-input, .text-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-light);
    background-color: white;
    color: var(--text-light);
    font-size: 1rem;
}

body.dark-mode .date-input,
body.dark-mode .text-input {
    border-color: var(--border-dark);
    background-color: var(--background-dark);
    color: var(--text-dark);
}

.date-input:focus,
.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 104, 55, 0.2);
}

/* Section Titles */
.section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 2rem 0 1rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(0, 104, 55, 0.1), rgba(0, 166, 81, 0.05));
    border-radius: 0.75rem;
    border-right: 4px solid var(--primary-color);
}

body.dark-mode .section-title {
    color: var(--primary-light);
    background: linear-gradient(135deg, rgba(0, 104, 55, 0.2), rgba(0, 166, 81, 0.1));
    border-right-color: var(--primary-light);
}

/* Results Section */
.result-section {
    margin-top: 2rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    background-color: white;
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-light);
    transition: transform 0.3s ease;
    border: 1px solid var(--border-light);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

body.dark-mode .result-card {
    background-color: rgba(31, 41, 55, 0.95);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

.result-card:hover {
    transform: translateY(-5px);
}

.next-birthday-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d);
    color: white;
    text-align: center;
    padding: 2rem;
}

.next-birthday-card .result-title {
    color: white;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.countdown-display {
    font-size: 1.8rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

body.dark-mode .result-title {
    color: var(--primary-light);
}

.result-title i {
    width: 24px;
    text-align: center;
}

.result-value {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 0.5rem;
    line-height: 1.4;
}

.english-digits {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    display: inline-block;
}

/* Family Comparison Styles */
.family-member {
    background-color: white;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

body.dark-mode .family-member {
    background-color: rgba(31, 41, 55, 0.95);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

.family-member-remove {
    background: var(--error-color);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

.family-member-remove:hover {
    transform: scale(1.1);
    background: #dc2626;
}

/* Button Styles */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: linear-gradient(to right, var(--primary-color), var(--primary-light));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 1rem;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: linear-gradient(to right, #64748b, #94a3b8);
}

.btn-danger {
    background: linear-gradient(to right, #dc2626, #ef4444);
}

.btn-primary {
    background: linear-gradient(to right, var(--primary-color), var(--primary-light));
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: auto;
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

/* History Section */
.history-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
}

body.dark-mode .history-section {
    border-top-color: var(--border-dark);
}

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

.history-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

body.dark-mode .history-title {
    color: var(--primary-light);
}

.history-item {
    background-color: white;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-light);
    animation: fadeIn 0.5s ease forwards;
    transition: transform 0.3s ease;
}

body.dark-mode .history-item {
    background-color: rgba(31, 41, 55, 0.95);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

.history-item:hover {
    transform: translateY(-3px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

body.dark-mode .history-item-header {
    border-bottom-color: var(--border-dark);
}

.history-date {
    font-weight: 600;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
}

.history-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    color: var(--text-light);
    background-color: var(--border-light);
}

body.dark-mode .history-btn {
    color: var(--text-dark);
    background-color: var(--border-dark);
}

.history-btn:hover {
    transform: scale(1.1);
}

.history-btn-copy {
    color: var(--primary-color);
}

.history-btn-search {
    color: var(--accent-color);
}

.history-btn-delete {
    color: var(--error-color);
}

.history-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.history-detail {
    padding: 0.5rem;
}

.history-detail-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

body.dark-mode .history-detail-title {
    color: var(--primary-light);
}

.history-detail-value {
    font-size: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    opacity: 0.7;
}

body.dark-mode .empty-state {
    color: var(--text-dark);
}

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

/* Loading and Error Messages */
.loading-message,
.error-message {
    text-align: center;
    padding: 3rem;
    border-radius: 1rem;
    background-color: white;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-light);
}

body.dark-mode .loading-message,
body.dark-mode .error-message {
    background-color: rgba(31, 41, 55, 0.95);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-dark);
}

.loading-message i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.error-message {
    color: var(--error-color);
}

.error-message i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-light);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background-color: var(--error-color);
}

.toast.success {
    background-color: var(--success-color);
}

/* Footer */
footer {
    margin-top: auto;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
}

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

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

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.hidden {
    display: none;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .result-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .container {
        padding: 0 0.5rem;
        margin-top: 1rem;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .logo img {
        height: 40px;
    }

    .age-calculator {
        padding: 1.25rem;
    }

    .calculator-title {
        font-size: 1.2rem;
    }

    .result-grid {
        grid-template-columns: 1fr;
    }

    .side-menu {
        width: 85%;
    }

    .history-details {
        grid-template-columns: 1fr;
    }

    .history-actions {
        flex-wrap: wrap;
    }

    .family-member {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .family-member-remove {
        justify-self: end;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .countdown-display {
        font-size: 1.4rem;
    }

    .next-birthday-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.25rem;
    }

    .age-calculator {
        padding: 1rem;
    }

    .result-card {
        padding: 1rem;
    }

    .section-title {
        font-size: 1.1rem;
        padding: 0.75rem;
    }

    .result-value {
        font-size: 1.1rem;
    }

    .countdown-display {
        font-size: 1.2rem;
    }
}