/**
 * Component Styles
 * Buttons, Inputs, Cards, Tables, and other UI components
 */

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
    text-align: center;
    white-space: nowrap;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
    background-color: var(--color-primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    background-color: var(--color-primary-active);
    transform: translateY(1px);
}

/* Secondary Button */
.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn-secondary:active:not(:disabled) {
    background-color: var(--bg-tertiary);
    transform: translateY(1px);
}

/* Tertiary/Ghost Button */
.btn-tertiary {
    background-color: transparent;
    color: var(--color-primary);
}

.btn-tertiary:hover:not(:disabled) {
    background-color: var(--color-primary-light);
}

.btn-tertiary:active:not(:disabled) {
    background-color: var(--bg-tertiary);
}

/* Danger Button */
.btn-danger {
    background-color: var(--color-error);
    color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
    background-color: #C41E28;
    box-shadow: var(--shadow-md);
}

.btn-danger:active:not(:disabled) {
    background-color: #A41820;
    transform: translateY(1px);
}

/* Success Button */
.btn-success {
    background-color: var(--color-success);
    color: var(--text-inverse);
}

.btn-success:hover:not(:disabled) {
    background-color: #198038;
    box-shadow: var(--shadow-md);
}

/* Icon Button */
.btn-icon {
    padding: var(--space-sm);
    min-width: 44px;
    width: 44px;
    height: 44px;
}

/* Button Sizes */
.btn-sm {
    min-height: 36px;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
}

.btn-lg {
    min-height: 52px;
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-lg);
}

.btn-full {
    width: 100%;
}

/* Button Group */
.button-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

/* ============================================================================
   INPUT FIELDS
   ============================================================================ */

.input,
.textarea,
.select {
    width: 100%;
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.input:hover,
.textarea:hover,
.select:hover {
    border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
    border-color: var(--border-interactive);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-placeholder);
}

/* Textarea */
.textarea {
    min-height: 120px;
    resize: vertical;
}

/* Select Dropdown */
.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23525252' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-md) center;
    padding-right: var(--space-2xl);
}

/* RTL Select */
body.rtl .select {
    background-position: left var(--space-md) center;
    padding-right: var(--space-md);
    padding-left: var(--space-2xl);
}

/* Select Size Variants */
.select-sm {
    min-height: 36px;
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-sm);
    padding-right: var(--space-xl);
}

/* Form Group */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}

.form-group .help-text {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* Input Group */
.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group .input {
    flex: 1;
}

/* Validation States */
.input.is-valid,
.select.is-valid,
.textarea.is-valid {
    border-color: var(--color-success);
}

.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid {
    border-color: var(--color-error);
}

.validation-msg {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--color-error);
}

/* ============================================================================
   RADIO BUTTONS & CHECKBOXES
   ============================================================================ */

.radio,
.checkbox {
    appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--border-strong);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.radio {
    border-radius: var(--radius-full);
}

.checkbox {
    border-radius: var(--radius-sm);
}

.radio:hover,
.checkbox:hover {
    border-color: var(--color-primary);
}

.radio:checked,
.checkbox:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-inverse);
}

.checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-inverse);
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

/* Radio/Checkbox Group */
.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.radio-group label,
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.radio-group label:hover,
.checkbox-group label:hover {
    background-color: var(--bg-secondary);
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2,
.card h3,
.card h4 {
    margin-top: 0;
}

.card-compact {
    padding: var(--space-md);
}

.card-bordered {
    border: 2px solid var(--border-color);
    box-shadow: none;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.table thead {
    background-color: var(--bg-secondary);
}

.table th {
    padding: var(--space-md);
    text-align: left;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* RTL Table */
body.rtl .table th,
body.rtl .table td {
    text-align: right;
}

/* Responsive Table */
@media (max-width: 767px) {
    .table-responsive {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================================
   ALERTS & NOTIFICATIONS
   ============================================================================ */

.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin-bottom: var(--space-md);
}

body.rtl .alert {
    border-left: none;
    border-right: 4px solid;
}

.alert-info {
    background-color: var(--color-info-light);
    border-color: var(--color-info);
    color: var(--text-primary);
}

.alert-success {
    background-color: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--text-primary);
}

.alert-warning {
    background-color: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--text-primary);
}

.alert-error {
    background-color: var(--color-error-light);
    border-color: var(--color-error);
    color: var(--text-primary);
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.loading-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-md);
}

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

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-primary {
    color: var(--text-primary);
}

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

.text-tertiary {
    color: var(--text-tertiary);
}

.font-bold {
    font-weight: var(--weight-bold);
}

.font-semibold {
    font-weight: var(--weight-semibold);
}

.font-medium {
    font-weight: var(--weight-medium);
}

.font-mono {
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

/* Touch Feedback for Mobile */
@media (hover: none) {
    .btn:active:not(:disabled),
    .input:active,
    .select:active {
        opacity: 0.8;
    }
}

/* ============================================================================
   CITY SEARCH RESULTS
   ============================================================================ */

.city-search-results {
    position: relative;
    z-index: 100;
}

.city-search-item {
    padding: var(--space-md);
    cursor: pointer;
    border-bottom: 1px solid var(--border-secondary);
    transition: background-color var(--transition-fast);
}

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

.city-search-item:hover,
.city-search-item.active {
    background-color: var(--bg-secondary);
}

.city-search-item .city-name {
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.city-search-item .city-details {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.city-search-item .city-coords {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
    font-family: monospace;
}

/* ============================================================================
   RANGE SLIDER (VOLUME CONTROL)
   ============================================================================ */

.range-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
    transition: background-color var(--transition-fast);
}

.range-slider:hover::-webkit-slider-thumb {
    background: var(--color-primary-hover);
}

.range-slider:hover::-moz-range-thumb {
    background: var(--color-primary-hover);
}

.range-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.range-slider:disabled::-webkit-slider-thumb {
    cursor: not-allowed;
}

.range-slider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

/* ============================================================================
   COOKIE CONSENT BANNER
   ============================================================================ */

.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 2px solid var(--color-primary);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: var(--space-lg);
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.cookie-consent.hidden {
    display: none;
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
}

.cookie-consent-content p {
    flex: 1;
    margin: 0;
    color: var(--text-primary);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.cookie-consent-content strong {
    color: var(--color-primary);
}

.cookie-consent-buttons {
    display: flex;
    gap: var(--space-md);
    flex-shrink: 0;
}

.cookie-consent-buttons .btn {
    min-width: 100px;
}

@media (max-width: 768px) {
    .cookie-consent-content {
        flex-direction: column;
        align-items: stretch;
    }

    .cookie-consent-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .cookie-consent-buttons .btn {
        flex: 1;
    }
}

/* ============================================================================
   COUNTDOWN TIMER
   ============================================================================ */

.countdown-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.5s ease-in;
}

.countdown-container {
    max-width: 500px;
    margin: 0 auto;
}

.countdown-label {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.countdown-prayer {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.countdown-time {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.1em;
}

.countdown-at {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .countdown-section {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .countdown-prayer {
        font-size: 2rem;
    }

    .countdown-time {
        font-size: 2.5rem;
    }
}

/* Dark mode support */
.dark-mode .countdown-section {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

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

/* ============================================================================
   PRAYER TIMES PLACEHOLDER
   ============================================================================ */

.prayer-times-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    gap: var(--space-md);
}

.prayer-times-placeholder svg {
    opacity: 0.5;
}

.prayer-times-placeholder p {
    color: var(--text-tertiary);
    font-size: var(--text-base);
    margin: 0;
}

/* ============================================================================
   QIBLA COMPASS
   ============================================================================ */

.qibla-compass-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: var(--space-lg) 0;
}

.qibla-compass {
    position: relative;
    width: 200px;
    height: 200px;
}

.qibla-compass svg {
    transform-origin: center;
}

#compassNeedle {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   INLINE STYLE REPLACEMENTS
   ============================================================================ */

.collapsible-panel {
    margin-top: var(--space-md);
}

.dst-status {
    display: block;
    margin-top: var(--space-xs);
}

.position-relative {
    position: relative;
}

.search-loading-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}

body.rtl .search-loading-indicator {
    right: auto;
    left: 10px;
}

.city-search-dropdown {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: var(--space-xs);
    background: var(--bg-primary);
}

.search-error-text {
    margin-top: var(--space-xs);
    font-size: var(--text-sm);
}

.qibla-info {
    margin-bottom: var(--space-md);
}

.form-option-indent {
    margin-top: var(--space-sm);
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: var(--space-lg) 0;
    padding-top: var(--space-lg);
}

.link-underline {
    text-decoration: underline;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-md {
    margin-bottom: var(--space-md);
}

.mt-md {
    margin-top: var(--space-md);
}
