/* Mobile Optimizations for 9:16 Format */

@media (max-width: 768px) {

    /* Top bar - sticky */
    .top-bar {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
        position: sticky;
        top: 0;
        background: var(--bg-color);
        backdrop-filter: blur(10px);
        z-index: 100;
        border-bottom: 1px solid var(--border);
    }

    .actions {
        width: 100%;
        gap: 0.75rem;
        margin-top: 0.75rem;
        display: flex;
        flex-wrap: wrap;
    }

    #add-task-btn {
        flex: 1;
        justify-content: center;
        padding: 0.875rem;
        font-size: 1rem;
        min-height: 50px;
    }

    #help-btn {
        flex: 0 0 auto;
        padding: 0.875rem;
        min-width: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #delete-project-btn {
        flex: 0 0 auto;
        padding: 0;
        min-width: 50px;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #delete-project-btn i {
        font-size: 1.1rem;
    }

    /* Main content must have fixed height */
    .main-content {
        height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Board container - scrollable */
    .board-container {
        flex: 1 !important;
        overflow-y: scroll !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 1rem !important;
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        height: auto !important;
    }

    .column {
        min-height: 300px !important;
        max-height: none !important;
    }

    .task-list {
        max-height: none !important;
        overflow-y: visible !important;
    }

    /* Login form spacing */
    #login-form button[type="submit"],
    #register-form button[type="submit"] {
        margin-top: 1.5rem;
    }

    /* Modal */
    .modal {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        padding: 1.5rem;
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
        margin: 0;
        border-radius: 16px;
    }

    .modal-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border);
    }

    .modal-header h2 {
        font-size: 1.3rem;
        margin: 0;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1.5rem;
    }

    .form-group:last-of-type {
        margin-bottom: 0;
    }

    label {
        font-size: 1rem;
        margin-bottom: 0.75rem;
        font-weight: 500;
        display: block;
    }

    .form-row {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    input,
    textarea,
    select {
        width: 100%;
        padding: 1rem;
        font-size: 16px !important;
        min-height: 52px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: var(--card-bg);
        color: var(--text-primary);
    }

    textarea {
        min-height: 100px;
        resize: vertical;
    }

    select {
        appearance: none;
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        background-size: 1.2rem;
        padding-right: 3rem;
    }

    body.light-mode select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    }

    .modal-footer {
        display: flex;
        gap: 1rem;
        margin-top: 2rem;
        padding-top: 1.5rem;
        border-top: 1px solid var(--border);
        flex-direction: row;
    }

    .modal-footer button {
        flex: 1;
        padding: 1rem;
        font-size: 1rem;
        min-height: 52px;
        justify-content: center;
        border-radius: 8px;
    }

    .close-modal {
        font-size: 1.5rem;
        padding: 0.5rem;
        min-width: 44px;
        min-height: 44px;
    }

    @media (max-height: 700px) {
        .column {
            min-height: 200px !important;
        }
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .modal {
        align-items: center;
        padding: 1rem;
    }

    .modal-content {
        max-width: 600px;
        max-height: calc(100vh - 2rem);
    }
}