/**
 * TempMail Styles - Responsive Mobile Fix
 */

.tempmail-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Ensure Tailwind utility classes work */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

.tempmail-container {
    font-family: 'Inter', sans-serif;
}

/* Custom email viewer content styles */
#email-viewer-content {
    line-height: 1.6;
}

#email-viewer-content h1,
#email-viewer-content h2,
#email-viewer-content h3,
#email-viewer-content h4,
#email-viewer-content h5,
#email-viewer-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

#email-viewer-content p {
    margin-bottom: 1em;
}

#email-viewer-content a {
    color: #3B82F6;
    text-decoration: underline;
}

#email-viewer-content ul,
#email-viewer-content ol {
    margin-left: 1.5em;
    margin-bottom: 1em;
}

#email-viewer-content li {
    margin-bottom: 0.5em;
}

/* Animation for new emails */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.email-item {
    animation: slideIn 0.3s ease-out;
}

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

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   DESKTOP STYLES - Add margins and center buttons
   ========================================================================== */

@media (min-width: 769px) {
    .tempmail-container {
        margin-left: 20px !important;
        margin-right: 20px !important;
    }

    /* Center action buttons on desktop */
    #account-section .flex.space-x-2 {
        justify-content: center !important;
    }
}

/* ==========================================================================
   RESPONSIVE MOBILE STYLES - Clean & Professional
   ========================================================================== */

@media (max-width: 768px) {
    /* Hide desktop logout button on mobile */
    #logout-btn {
        display: none !important;
    }
    /* Reset container with small side margins for mobile */
    .tempmail-container {
        padding: 0 !important;
        margin-left: 10px !important;
        margin-right: 10px !important;
        width: auto !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Hide desktop logout button on mobile */
    #logout-btn {
        display: none !important;
    }

    /* Remove card backgrounds for cleaner mobile look */
    .tempmail-container .bg-white.rounded-lg.shadow-md {
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 1rem 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Header section mobile optimization */
    #account-section,
    #login-section {
        padding: 0.75rem 0.5rem !important;
    }

    /* Input fields full width on mobile */
    #account-section input,
    #login-section input {
        width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
    }

    /* Email field row - 80% email, 20% copy button */
    #current-email {
        flex: 0 0 80% !important;
        max-width: 80% !important;
    }

    #copy-email-btn {
        flex: 0 0 20% !important;
        max-width: 20% !important;
        min-width: 50px !important;
    }

    /* Password field row - 80% password, 20% toggle button */
    #current-password {
        flex: 0 0 80% !important;
        max-width: 80% !important;
    }

    #toggle-password {
        flex: 0 0 20% !important;
        max-width: 20% !important;
        min-width: 50px !important;
    }

    /* Button groups - Keep refresh and new email in 2 equal columns */
    #account-section .flex.space-x-2 {
        flex-direction: row !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }

    #refresh-btn,
    #new-email-btn {
        flex: 1 !important;
        width: 50% !important;
        margin: 0 !important;
        padding: 0.75rem !important;
        justify-content: center !important;
    }

    /* Hide logout button completely on mobile (we have the link below) */
    /* Already handled above at line 100-105 */

    /* Style logout link text */
    #account-section .mt-3 {
        margin-top: 1rem !important;
    }

    /* Email display row - better spacing */
    .flex.items-center.space-x-2 {
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Copy and toggle buttons - appropriate size */
    #copy-email-btn,
    #toggle-password {
        min-width: 50px !important;
        padding: 0.75rem !important;
    }

    /* Inbox mobile optimization */
    #inbox-section {
        padding: 0.75rem 0.5rem !important;
    }

    /* Email list items - compact and professional */
    .email-item {
        padding: 0.875rem 0.625rem !important;
        margin: 0.4rem 0 !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 0.5rem !important;
        background: white !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    }

    /* Unread emails - subtle highlight */
    .email-item.border-blue-300 {
        border-color: #93c5fd !important;
        background: #eff6ff !important;
    }

    /* Compact spacing in email items */
    .email-item .space-x-2 {
        gap: 0.75rem !important;
    }

    .email-item .mb-1 {
        margin-bottom: 0.25rem !important;
    }

    /* Truncate long content */
    .email-sender,
    .email-subject {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 100% !important;
    }

    .email-preview {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 200px !important;
        font-size: 0.875rem !important;
        color: #6b7280 !important;
    }

    /* Single email view mobile optimization */
    #email-view-section {
        padding: 0.75rem 0.5rem !important;
    }

    #back-to-inbox-btn {
        padding: 0.75rem 1rem !important;
        margin-bottom: 1rem !important;
    }

    #email-viewer-content {
        font-size: 0.875rem !important;
        line-height: 1.6 !important;
    }

    #email-viewer-content img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Alert messages mobile positioning */
    #alert-container {
        position: fixed !important;
        top: 1rem !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        z-index: 1000 !important;
    }

    #alert-container div {
        margin-bottom: 0.5rem !important;
        padding: 1rem !important;
        border-radius: 0.5rem !important;
    }

    /* Loading overlay mobile fix */
    #loading-overlay {
        padding: 1rem !important;
    }

    #loading-overlay > div {
        padding: 2rem !important;
        margin: 1rem !important;
    }

    /* Hide delete selected button on mobile */
    #delete-selected-btn {
        display: none !important;
    }

    /* Mobile logout link styling */
    #logout-link-mobile {
        text-decoration: underline !important;
        color: #ef4444 !important;
        font-size: 0.875rem !important;
    }

    /* Ensure proper touch targets */
    button:not(#logout-btn), 
    .email-item,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Mobile logout link styling */
    #logout-link-mobile {
        text-decoration: underline !important;
        color: #ef4444 !important;
        font-size: 0.875rem !important;
    }

    /* Better spacing for form elements */
    .grid.grid-cols-1.md\:grid-cols-2.gap-4 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Email action buttons */
    .email-item .flex.items-center.space-x-2 {
        gap: 0.5rem !important;
    }

    /* Date text smaller on mobile */
    .email-date {
        font-size: 0.75rem !important;
        margin-top: 0.25rem !important;
    }

    /* Compact email sender and subject */
    .email-item .email-sender,
    .email-item .email-subject {
        margin-bottom: 0.25rem !important;
    }

    .email-item .email-preview {
        margin-bottom: 0.25rem !important;
    }

    /* Logout text update for mobile */
    #logout-btn {
        font-size: 0.875rem !important;
        text-decoration: underline !important;
    }

    /* Prevent horizontal scroll */
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }
}

/* Very small mobile devices */
@media (max-width: 380px) {
    .tempmail-container {
        padding: 0 0.25rem !important;
    }
    
    .tempmail-container .bg-white.rounded-lg.shadow-md {
        padding: 0.5rem 0.25rem !important;
    }

    /* Even more compact for very small screens */
    .email-item {
        padding: 0.75rem 0.5rem !important;
    }

    .email-preview {
        max-width: 150px !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .tempmail-container {
        max-width: 100% !important;
        padding: 1rem !important;
    }
}

/* Print styles */
@media print {
    .tempmail-container button {
        display: none !important;
    }
}

/* Focus styles for accessibility */
.tempmail-container *:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Smooth transitions */
.tempmail-container * {
    transition: all 0.2s ease-in-out;
}
