/* Mobile-First CSS - Optimized for Performance */

/* CSS Reset & Base Styles */
*,*::before,*::after{box-sizing:border-box}
*{margin:0;padding:0}
html{-webkit-text-size-adjust:100%}
body{line-height:1.5;-webkit-font-smoothing:antialiased}
img,picture,video,canvas,svg{display:block;max-width:100%}
input,button,textarea,select{font:inherit}
p,h1,h2,h3,h4,h5,h6{overflow-wrap:break-word}

/* CSS Variables for Performance */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #f6ad55;
    --accent-dark: #ed8936;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* Base Styles - Mobile First */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    min-height: 100vh;
    color: var(--gray-700);
    font-size: 16px;
    overflow-x: hidden;
    /* Enhanced mobile optimizations */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection for content areas */
.prayer-section textarea,
.content-section,
.instructions p {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 8px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
}

/* Header - Mobile Optimized */
header {
    text-align: center;
    margin-bottom: 12px;
    color: var(--white);
    padding: 8px 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    line-height: 1.2;
}

header p {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Main Content */
main {
    flex: 1;
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    margin-bottom: 8px;
}

/* Quick Actions - Mobile Priority */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.primary-btn, .secondary-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* iOS minimum touch target */
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--white);
    box-shadow: var(--shadow);
}

.primary-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.secondary-btn {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.secondary-btn:active {
    background: var(--gray-200);
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Counter Display - Mobile Optimized */
.counter-display {
    text-align: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.counter-main {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    line-height: 1;
}

.separator {
    color: var(--gray-300);
    margin: 0 3px;
}

.counter-label {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 10px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Controls - Mobile Optimized */
.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.control-group label {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
}

.control-group select {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.85rem;
    min-width: 130px;
    min-height: 36px; /* Touch-friendly */
}

/* Toggle Switch */
.toggle-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--gray-300);
    border-radius: 12px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--white);
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Prayer Beads - Hidden on Mobile */
.prayer-beads-container {
    display: none;
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 20px;
}

.beads-circle {
    position: relative;
    width: 100%;
    height: 100%;
}

.bead {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-300);
    border: 1px solid var(--gray-400);
    transition: var(--transition);
    cursor: pointer;
    transform: translate(-50%, -50%);
}

.bead.completed {
    background: var(--primary);
    border-color: var(--primary-dark);
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.4);
}

.bead.current {
    background: var(--accent);
    border-color: var(--accent-dark);
    box-shadow: 0 0 12px rgba(246, 173, 85, 0.6);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.4); }
}

/* Prayer Section */
.prayer-section {
    margin-bottom: 16px;
}

.prayer-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
}

.prayer-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    resize: vertical;
    transition: var(--transition);
    background: var(--white);
    min-height: 60px;
    /* Mobile keyboard optimizations */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.prayer-section textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Instructions */
.instructions {
    padding: 10px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    margin-bottom: 12px;
}

.instructions p {
    font-size: 0.8rem;
    color: var(--gray-600);
    line-height: 1.4;
}

/* Footer */
footer {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
}

.footer-content {
    text-align: center;
    padding: 20px 0;
}

.footer-nav {
    margin: 12px 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-nav a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.8rem;
    transition: var(--transition);
}

.footer-nav a:hover {
    color: var(--white);
    text-decoration: underline;
}

.copyright {
    margin-top: 8px;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* AdSense Containers */
.ad-container {
    margin: 20px 0;
    text-align: center;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-banner-top {
    margin: 10px 0 20px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 10px;
}

.ad-banner-bottom {
    margin: 20px 0 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 10px;
}

.ad-sidebar {
    display: none;
}

.ad-in-content {
    margin: 30px 0;
    padding: 15px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

/* Content Section for SEO */
.content-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.content-section h2 {
    font-size: 1.3rem;
    color: var(--gray-700);
    margin-bottom: 12px;
    text-align: center;
}

.content-section h3 {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin: 20px 0 10px 0;
}

.content-section h4 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.content-section p {
    line-height: 1.5;
    margin-bottom: 10px;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.prayer-info {
    display: grid;
    gap: 16px;
    margin: 20px 0;
}

.prayer-card {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.benefits-list, .steps-list {
    margin: 16px 0;
    padding-left: 20px;
}

.benefits-list li, .steps-list li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--gray-600);
}

.benefits-list strong {
    color: var(--gray-700);
}

/* Tablet Styles */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 20px;
    }
    
    header h1 {
        font-size: 2.25rem;
    }
    
    main {
        padding: 24px;
    }
    
    .quick-actions {
        max-width: 400px;
        margin: 0 auto 24px;
    }
    
    .controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .prayer-beads-container {
        display: block;
        width: 320px;
        height: 320px;
    }
    
    .bead {
        width: 14px;
        height: 14px;
    }
}

/* Desktop Styles */
@media (min-width: 1024px) {
    .container {
        max-width: 800px;
        padding: 24px;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    main {
        padding: 32px;
        position: relative;
    }
    
    .prayer-beads-container {
        width: 400px;
        height: 400px;
    }
    
    .bead {
        width: 16px;
        height: 16px;
    }
    
    .bead:hover {
        transform: translate(-50%, -50%) scale(1.2);
    }
    
    .primary-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 12px rgba(102, 126, 234, 0.3);
    }
    
    .secondary-btn:hover {
        background: var(--gray-200);
        transform: translateY(-1px);
    }
    
    /* Desktop Sidebar Ad */
    .ad-sidebar {
        display: block;
        position: absolute;
        right: -200px;
        top: 50%;
        transform: translateY(-50%);
        width: 160px;
        height: 600px;
    }
    
    .prayer-info {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .footer-nav {
        gap: 30px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .bead {
        border-width: 0.5px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-300: #6b7280;
        --gray-600: #d1d5db;
        --gray-700: #f3f4f6;
    }
    
    main {
        background: rgba(31, 41, 55, 0.95);
        color: var(--gray-700);
    }
}