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

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%; /* Prevent text size adjustment on iOS */
}

/* Better scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

:root {
    --primary: #6366f1;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --light: #f9fafb;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --gradient-5: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
}

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

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 30px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.5s ease;
}

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

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s ease-in-out infinite;
}

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

.tagline {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 300;
}

.add-promise-btn {
    background: var(--gradient-2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

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

/* Search Container */
.search-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    margin-top: 20px;
}

.search-container .container {
    display: flex;
    gap: 10px;
    max-width: 600px;
}

#searchInput {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 50px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#searchBtn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

#searchBtn:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

.refresh-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.5s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.refresh-btn:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

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

/* Filter Container */
.filter-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    margin-top: 2px;
}

.filter-container .container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-btn {
    padding: 10px 20px;
    border: 2px solid #e5e7eb;
    background: white;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--gradient-1);
    color: white;
    border-color: transparent;
}

/* Searched/Highlighted Promise */
.promise-card.searched {
    border: 4px solid #fbbf24;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2), 0 20px 60px rgba(251, 191, 36, 0.3);
    position: relative;
    animation: pulseGlow 2s ease-in-out infinite;
    order: -999; /* Bring to top of grid */
    scroll-margin-top: 150px; /* Space from top when scrolled into view */
    margin-top: 20px; /* Extra spacing from elements above */
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2), 0 20px 60px rgba(251, 191, 36, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.4), 0 25px 70px rgba(251, 191, 36, 0.5);
    }
}

.promise-card.searched::after {
    content: '📌 FOUND';
    position: absolute;
    top: -12px;
    right: 20px;
    background: #fbbf24;
    color: #78350f;
    padding: 6px 20px;
    font-weight: 700;
    font-size: 0.7rem;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
    z-index: 10;
    letter-spacing: 1px;
}

/* Promise Wall */
main {
    padding: 60px 20px 40px;
    min-height: 60vh;
}

main.main-content {
    margin-top: 30px;
}

.promise-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Promise Card */
.promise-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    animation: cardPop 0.5s ease;
}

@keyframes cardPop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.promise-card:hover {
    transform: translateY(-10px) rotate(1deg);
    box-shadow: var(--shadow-lg);
}

.promise-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--gradient-1);
}

.promise-card.personal::before { background: var(--gradient-1); }
.promise-card.work::before { background: var(--gradient-2); }
.promise-card.health::before { background: var(--gradient-3); }
.promise-card.relationships::before { background: var(--gradient-4); }
.promise-card.fun::before { background: var(--gradient-5); }
.promise-card.other::before { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

.promise-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.promise-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.promise-id {
    background: #f3f4f6;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
}

.category-badge {
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.category-badge.personal { background: #ddd6fe; color: #5b21b6; }
.category-badge.work { background: #fce7f3; color: #be185d; }
.category-badge.health { background: #dbeafe; color: #1e40af; }
.category-badge.relationships { background: #d1fae5; color: #065f46; }
.category-badge.fun { background: #fef3c7; color: #92400e; }
.category-badge.other { background: #f3e8ff; color: #6b21a8; }

.promise-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark);
    line-height: 1.4;
}

.promise-description {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.6;
}

.promise-deadline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--dark);
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.countdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.countdown-item {
    background: #f9fafb;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.countdown-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.countdown-label {
    display: block;
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    margin-top: 3px;
}

/* Progress Bar */
.progress-container {
    margin-top: 15px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 8px;
}

.progress-bar {
    height: 12px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-1);
    border-radius: 10px;
    transition: width 1s ease;
    position: relative;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* Share Button */
.share-promise-btn {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.share-promise-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: white;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.empty-state h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 40px;
    border-radius: 25px;
    max-width: 600px;
    position: relative;
    animation: slideUp 0.3s ease;
}

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

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--danger);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    text-align: center;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Error Box */
.error-box {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 3px solid #f59e0b;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    align-items: start;
    gap: 15px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.error-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.error-content h3 {
    color: #92400e;
    font-size: 1.1rem;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.error-content {
    flex: 1;
}

#promiseErrorMessage {
    color: #78350f;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
}

#promiseErrorMessage p {
    margin: 8px 0;
}

/* Form Styles */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Field-specific error messages */
.field-error {
    display: none;
    margin-top: 8px;
    padding: 10px 15px;
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #991b1b;
    line-height: 1.5;
    animation: slideDown 0.3s ease;
}

.field-error:not(:empty) {
    display: block;
}

.field-error::before {
    content: "⚠️ ";
    margin-right: 5px;
}

.form-group.has-error input,
.form-group.has-error textarea {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.form-group.has-error input:focus,
.form-group.has-error textarea:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.95rem;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Honeypot field - hidden from users */
.honeypot-field {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.captcha {
    background: #f9fafb;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

#captchaQuestion {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.submit-btn {
    width: 100%;
    padding: 15px;
    background: var(--gradient-1);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

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

/* Ad Modal */
.ad-modal {
    z-index: 1001 !important;
}

.ad-modal.active {
    display: block !important;
}

.ad-modal .modal-content {
    max-width: 550px;
}

.ad-content h2 {
    margin-bottom: 20px;
}

/* Promise ID Warning */
.promise-id-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 3px solid #f59e0b;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    text-align: center;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
}

.warning-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

.promise-id-warning h3 {
    color: #92400e;
    font-size: 1.4rem;
    margin-bottom: 15px;
}

.promise-id-display {
    background: white;
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.promise-id-code {
    font-size: 1.8rem;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    letter-spacing: 3px;
    padding: 8px 15px;
    background: #f3f4f6;
    border-radius: 8px;
    user-select: all;
}

.copy-id-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.copy-id-btn:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

.copy-id-btn:active {
    transform: scale(0.95);
}

.copy-id-btn.copied {
    background: var(--success);
}

.warning-message {
    color: #92400e;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 10px 0 0 0;
}

.ad-space {
    margin: 25px 0;
}

.ad-placeholder-popup {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 60px;
    border-radius: 15px;
    text-align: center;
    border: 2px dashed #9ca3af;
}

.ad-message {
    margin-top: 10px;
    color: #6b7280;
    font-size: 0.9rem;
}

.close-ad,
.close-ad-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.close-ad-btn:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

/* AdSense Banner */
.adsense-banner {
    background: white;
    padding: 30px;
    margin-top: 40px;
}

.ad-placeholder {
    max-width: 970px;
    margin: 0 auto;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    border: 2px dashed #9ca3af;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    text-align: center;
    color: var(--dark);
    font-weight: 500;
}

/* Responsive Design */

/* Tablets and small laptops (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 15px;
    }

    .promise-wall {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }

    .modal-content {
        max-width: 90%;
        margin: 5% auto;
    }
}

/* Tablets (768px and below) */
@media (max-width: 768px) {
    /* Header */
    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 0.85rem;
    }

    header .container {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .header-left {
        align-items: center;
    }

    .header-right {
        justify-content: center;
        width: 100%;
    }

    .add-promise-btn {
        width: 100%;
        max-width: 300px;
    }

    /* Search Bar */
    .search-container .container {
        flex-direction: column;
        max-width: 100%;
        gap: 12px;
    }

    #searchInput {
        width: 100%;
    }

    #searchBtn,
    .refresh-btn {
        width: 100%;
        padding: 14px;
        font-size: 1rem;
    }

    /* Filter Buttons */
    .filter-container .container {
        gap: 8px;
        justify-content: center;
    }

    .filter-btn {
        padding: 10px 16px;
        font-size: 0.8rem;
        flex: 1;
        min-width: 80px;
    }

    /* Promise Cards */
    .promise-wall {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .promise-card {
        padding: 20px;
    }

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

    .countdown {
        gap: 6px;
    }

    .countdown-value {
        font-size: 1.3rem;
    }

    .countdown-label {
        font-size: 0.65rem;
    }

    /* Modal */
    .modal-content {
        margin: 5% 15px;
        padding: 25px 15px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-content h2 {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group {
        margin-bottom: 20px;
    }

    /* Ad Modal */
    .promise-id-warning {
        padding: 20px;
    }

    .promise-id-warning h3 {
        font-size: 1.2rem;
    }

    .promise-id-code {
        font-size: 1.2rem;
    }

    /* Empty State */
    .empty-state {
        padding: 60px 20px;
    }

    .empty-icon {
        font-size: 4rem;
    }

    .empty-state h2 {
        font-size: 1.6rem;
    }

    /* Footer */
    footer {
        padding: 20px;
        font-size: 0.9rem;
    }
}

/* Large Phones (640px and below) */
@media (max-width: 640px) {
    /* Header */
    .logo {
        font-size: 1.8rem;
    }

    header {
        padding: 20px 0;
    }

    /* Search */
    .search-container,
    .filter-container {
        padding: 15px 0;
    }

    /* Promise Cards */
    .promise-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .promise-id {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .category-badge {
        font-size: 0.65rem;
        padding: 4px 12px;
    }

    .share-promise-btn {
        font-size: 0.7rem;
        padding: 5px 10px;
    }

    .promise-title {
        font-size: 1.1rem;
    }

    .promise-description {
        font-size: 0.9rem;
    }

    /* Countdown - 2x2 grid on small screens */
    .countdown {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .countdown-item {
        padding: 12px 8px;
    }

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

    .countdown-label {
        font-size: 0.65rem;
    }

    /* Modal */
    .modal-content {
        margin: 3% 10px;
        padding: 20px 12px;
        border-radius: 15px;
    }

    .modal-content h2 {
        font-size: 1.4rem;
    }

    input[type="text"],
    input[type="date"],
    input[type="time"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px;
    }

    label {
        font-size: 0.9rem;
    }

    .submit-btn {
        padding: 16px;
        font-size: 1rem;
    }

    /* Close buttons - bigger touch targets */
    .close,
    .close-ad {
        width: 40px;
        height: 40px;
        font-size: 2rem;
        line-height: 40px;
    }
}

/* Small Phones (480px and below) */
@media (max-width: 480px) {
    /* Header */
    .logo {
        font-size: 1.6rem;
    }

    .tagline {
        font-size: 0.75rem;
    }

    .add-promise-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    /* Filter buttons - smaller on tiny screens */
    .filter-btn {
        padding: 8px 12px;
        font-size: 0.75rem;
        min-width: 70px;
    }

    /* Promise Cards */
    .promise-card {
        padding: 15px;
    }

    .promise-title {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .promise-description {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }

    .promise-deadline {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }

    /* Countdown */
    .countdown-item {
        padding: 10px 6px;
    }

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

    .countdown-label {
        font-size: 0.6rem;
    }

    /* Progress Bar */
    .progress-label {
        font-size: 0.75rem;
    }

    .progress-bar {
        height: 10px;
    }

    /* Modal */
    .modal-content {
        margin: 2% 8px;
        padding: 18px 10px;
    }

    .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .form-group {
        margin-bottom: 18px;
    }

    /* Promise ID Warning */
    .promise-id-warning {
        padding: 15px;
    }

    .promise-id-warning h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .promise-id-code {
        font-size: 1.1rem;
        padding: 10px;
    }

    .copy-id-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    /* Empty State */
    .empty-state {
        padding: 40px 15px;
    }

    .empty-icon {
        font-size: 3rem;
    }

    .empty-state h2 {
        font-size: 1.4rem;
    }

    .empty-state p {
        font-size: 0.9rem;
    }

    /* Footer */
    footer {
        padding: 15px;
        font-size: 0.85rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Bigger touch targets */
    .filter-btn,
    .add-promise-btn,
    #searchBtn,
    .refresh-btn,
    .share-promise-btn {
        min-height: 44px; /* Apple's recommended minimum */
    }

    /* Remove hover effects on touch devices */
    .promise-card:hover {
        transform: none;
    }

    /* Tap highlights */
    button,
    .filter-btn,
    .promise-card {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
}

/* Landscape mode on phones */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
        margin: 2% auto;
    }

    header {
        padding: 15px 0;
    }

    .promise-wall {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 15px;
    }
}

/* iPad Pro and tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .promise-wall {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .container {
        max-width: 95%;
    }
}

/* Expired Promise */
.promise-card.expired {
    opacity: 0.85;
    border: 2px solid var(--danger);
    background: linear-gradient(135deg, #fff 0%, #fee2e2 100%);
}

.promise-card.expired::before {
    background: var(--danger);
    height: 6px;
}

.promise-card.expired .progress-fill {
    background: var(--danger);
}

.promise-card.expired .countdown-value {
    color: var(--danger);
}

.promise-card.expired::after {
    content: '⏰ EXPIRED';
    position: absolute;
    top: 20px;
    right: -10px;
    background: var(--danger);
    color: white;
    padding: 8px 25px;
    font-weight: 700;
    font-size: 0.75rem;
    transform: rotate(15deg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    z-index: 10;
    letter-spacing: 1px;
}

.promise-card.expired .promise-title {
    color: #991b1b;
}

.promise-card.expired .countdown-item {
    background: #fee2e2;
}

/* Completed Progress */
.promise-card.completed .progress-fill {
    background: var(--success);
}
