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

:root {
    --primary-color: #1e7e34;
    --primary-dark: #155724;
    --primary-light: #2e9e4a;
    --secondary-color: #28a745;
    --background: linear-gradient(135deg, #f5f7fa 0%, #e8f5e9 100%);
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.9);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #e0e7e9;
    --error-color: #dc3545;
    --success-color: #28a745;
    --shadow-sm: 0 2px 8px rgba(30, 126, 52, 0.08);
    --shadow-md: 0 4px 16px rgba(30, 126, 52, 0.12);
    --shadow-lg: 0 8px 24px rgba(30, 126, 52, 0.16);
    --shadow-xl: 0 12px 40px rgba(30, 126, 52, 0.2);
    --nav-height: 70px;
    --header-height: 60px;
    --border-radius-sm: 12px;
    --border-radius-md: 16px;
    --border-radius-lg: 20px;
    --border-radius-xl: 24px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    background-image: linear-gradient(135deg, #f5f7fa 0%, #e8f5e9 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

#app {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Main Content */
#mainContent {
    flex: 1;
    padding-bottom: calc(var(--nav-height) + 20px);
    overflow-y: auto;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
    display: block;
}

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

/* Headings */
h2 {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
    letter-spacing: -0.5px;
}

h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 20px 0 10px;
}

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

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

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    background: var(--surface);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(30, 126, 52, 0.1), var(--shadow-md);
    transform: translateY(-1px);
}

.form-group input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: linear-gradient(to right, var(--border-color) 0%, var(--border-color) 100%);
    border-radius: 10px;
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(30, 126, 52, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(30, 126, 52, 0.4);
}

.form-group input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 2px 8px rgba(30, 126, 52, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(30, 126, 52, 0.4);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-range input {
    flex: 1;
}

.date-range span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mode-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    padding: 6px;
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.mode-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--border-radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.mode-btn:hover:not(.active) {
    background: var(--border-color);
    color: var(--text-primary);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: var(--shadow-md);
    transform: scale(1.02);
}

/* Results */
.results {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin-top: 30px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
}

.period-summary {
    margin-bottom: 15px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-item:hover {
    padding-left: 8px;
    color: var(--primary-color);
}

.result-item:last-of-type {
    border-bottom: none;
}

.result-total {
    display: flex;
    justify-content: space-between;
    padding: 18px;
    margin-top: 12px;
    border-radius: var(--border-radius-md);
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f4 100%);
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.result-total .result-label,
.result-total .result-value {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Period Selection */
.period-selector {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.period-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(30, 126, 52, 0.1), var(--shadow-md);
}

.period-option {
    margin-top: 15px;
}

/* Location Selector */
.location-selector {
    margin-bottom: 20px;
}

.or-divider {
    text-align: center;
    margin: 15px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Next Prayer Countdown */
.next-prayer-box {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius-xl);
    padding: 32px;
    margin: 20px 0;
    text-align: center;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.next-prayer-box::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.next-prayer-label {
    font-size: 0.9rem;
    opacity: 0.95;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.next-prayer-name {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -1px;
    position: relative;
    z-index: 1;
}

.next-prayer-time {
    font-size: 1.2rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.next-prayer-time span {
    font-size: 1.6rem;
    font-weight: 700;
}

/* Prayer Times */
.prayer-times {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 12px;
    margin-top: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
}

.prayer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin: 4px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prayer-item:last-child {
    border-bottom: none;
}

.prayer-item:hover {
    background: #f8fdf8;
    transform: translateX(4px);
}

.prayer-item.active {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8f4 100%);
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.prayer-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.05rem;
}

.prayer-time {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Qiblat Section */
.qiblat-input-section {
    margin-bottom: 20px;
}

.coordinate-inputs {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.coord-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--surface);
}

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

/* Qiblat Info Box */
.qiblat-info-box {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin: 20px 0;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
}

.qiblat-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.qiblat-stat:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.stat-value {
    font-weight: 700;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Compass */
.compass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0;
}

.compass-circle {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    position: relative;
    box-shadow: var(--shadow-xl), inset 0 0 40px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    height: 90%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.compass-needle {
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-bottom: 130px solid #ffd700;
    position: absolute;
    transform-origin: center bottom;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.compass-north {
    position: absolute;
    top: 15px;
    color: white;
    font-weight: 800;
    font-size: 1.6rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.compass-label {
    position: absolute;
    bottom: 35px;
    color: white;
    font-weight: 700;
    font-size: 1.3rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.compass-degree {
    margin-top: 24px;
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Leaflet Map Overrides */
#qiblatMap {
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    font-family: inherit;
}

/* Direction Adjustment */
.direction-adjustment {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
}

.direction-adjustment h3 {
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 18px;
}

/* Contact Page */
.contact-intro {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.contact-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 24px;
    background: var(--surface);
    border-radius: var(--border-radius-md);
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.contact-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.contact-link .icon {
    font-size: 1.8rem;
}

.contact-form {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(30, 126, 52, 0.08);
}

/* Info and Error Messages */
.info-text {
    margin-top: 15px;
    padding: 16px;
    border-radius: var(--border-radius-md);
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    text-align: center;
    border-left: 4px solid #17a2b8;
    box-shadow: var(--shadow-sm);
}

.error-text {
    margin-top: 15px;
    padding: 16px;
    border-radius: var(--border-radius-md);
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    text-align: center;
    border-left: 4px solid #dc3545;
    box-shadow: var(--shadow-sm);
}

/* Bottom Navigation */
#bottomNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(30, 126, 52, 0.1);
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -4px 16px rgba(30, 126, 52, 0.08);
    z-index: 1000;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 8px;
    position: relative;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 40px;
    height: 3px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 0 0 3px 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-btn:hover:not(.active) {
    color: var(--text-primary);
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Disclaimer */
.disclaimer {
    position: fixed;
    bottom: calc(var(--nav-height) + 5px);
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 5px;
    background: rgba(248, 249, 250, 0.95);
    z-index: 999;
}

/* Responsive Design */
@media (min-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .container {
        padding: 30px;
    }

    .mode-selector {
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* PWA Fullscreen Support */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Loading Animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(30, 126, 52, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Selection Style */
::selection {
    background: var(--primary-color);
    color: white;
}

::-moz-selection {
    background: var(--primary-color);
    color: white;
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
