/**
 * Mobile-optimized styles for Jause Ordering System
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    padding: 0;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Typography */
h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: #34495e;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #34495e;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

/* Forms */
.form-group {
    margin-bottom: 1rem;
    margin-top: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ced4da;
    border-radius: 0.5rem;
    background: #fff;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

textarea.form-control {
    resize: vertical;
    font-family: inherit;
}

/* Week selection dropdown - important, make it bigger and bold */
label[for="week_start"] {
    font-weight: 700;
    font-size: 1.125rem;
    color: #2c3e50;
}

#week_start {
    font-size: 1.125rem;
    font-weight: 700;
    padding: 1rem;
    border: 2px solid #007bff;
    background-color: #f8f9fa;
}

#week_start:focus {
    border-color: #0056b3;
    background-color: #fff;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Login page */
.login-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-container h2 {
    text-align: center;
    font-size: 1.25rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.login-form {
    margin-top: 1.5rem;
}

/* Pattern lock */
.pattern-lock-container {
    text-align: center;
}

.pattern-lock-container .instruction {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #6c757d;
}

#patternCanvas {
    display: block;
    margin: 0 auto 1rem;
    border: 2px solid #ddd;
    border-radius: 0.5rem;
    background: #fafafa;
    touch-action: none;
    max-width: 100%;
}

#loginForm {
    xdisplay: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Order form */
.order-form {
    background: #fff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-section {
    margin-top: 2rem;
}

.form-section h2 {
    margin-bottom: 0.5rem;
}

.help-text {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.food-items {
    margin-top: 1rem;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    gap: 1rem;
}

.food-item-info {
    flex: 1;
}

.food-item-name {
    display: block;
    font-weight: 500;
    font-size: 1.3rem;
    margin-bottom: 0.25rem;
}

.food-item-description {
    display: block;
    font-size: 1rem;
    color: #6c757d;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quantity-input {
    width: 60px;
    padding: 0.5rem;
    text-align: center;
    font-size: 1.125rem;
    font-weight: 500;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
}

.btn-quantity {
    width: 48px;
    height: 48px;
    padding: 0;
    font-size: 1.75rem;
    line-height: 1;
    border-radius: 50%;
    background: #007bff;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    /* Better mobile touch target */
    min-width: 48px;
    min-height: 48px;
}

.btn-quantity:hover {
    background: #0056b3;
}

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

/* Summary page */
.summary-box {
    background: #fff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

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

.summary-label {
    font-weight: 500;
    color: #6c757d;
}

.summary-value {
    font-weight: 600;
    color: #212529;
}

.summary-section {
    margin-top: 1.5rem;
}

.items-list {
    list-style: none;
    margin-top: 0.5rem;
}

.items-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f8f9fa;
    margin-bottom: 0.5rem;
    border-radius: 0.375rem;
}

.item-quantity {
    font-weight: 600;
    color: #007bff;
}

.no-items {
    color: #6c757d;
    font-style: italic;
}

/* Admin dashboard */
.week-selector {
    background: #fff;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.week-selector form {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.week-selector label {
    font-weight: 500;
}

.week-selector select {
    flex: 1;
    min-width: 200px;
}

.dashboard-section {
    margin-top: 1.5rem;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* User area: Accordion orders list */
.orders-list {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.accordion-item {
    border-bottom: 1px solid #dee2e6;
    background: #fff;
    padding: 1rem;
}

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

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    tap-highlight-color: transparent;
}

.accordion-header:active {
    background-color: #f0f4f8;
}

.accordion-date {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
}

.accordion-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.accordion-arrow {
    font-size: 0.75rem;
    color: #6c757d;
    transition: color 0.2s;
}

.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 1rem;
    padding-right: 1rem;
}

.accordion-body.open {
    max-height: 500px;
}

.order-items-table {
    width: 100%;
    border-collapse: collapse;
    background: #f8f9fa;
}

.order-items-table th {
    text-align: left;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #dee2e6;
}

.order-items-table td {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid #eee;
}

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

.order-items-table .col-amount {
    text-align: right;
    font-weight: 600;
    color: #007bff;
}

.order-items-table th.col-amount {
    text-align: right;
}

/* Editor pages (classes, food items) */
.editor-list .accordion-body.open {
    max-height: 800px;
    background-color: #f8f9fa;
}

.badge-inactive {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    background: #f8d7da;
    color: #721c24;
    border-radius: 0.25rem;
}

.editor-form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.editor-form-row .form-group {
    flex: 1;
}

.editor-checkbox {
    padding-bottom: 0.4rem;
}

.editor-checkbox label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    cursor: pointer;
}

.editor-checkbox input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.editor-add-section {
    margin-top: 1.5rem;
}

.editor-add-form {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.editor-add-form.open {
    max-height: 600px;
}

.editor-add-form form {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
}

.orders-table-container {
    background: #fff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.orders-table th,
.orders-table td {
    padding: 0.75rem;
    text-align: center;
    border: 1px solid #dee2e6;
}

.orders-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.orders-table .item-name {
    text-align: left;
    font-weight: 500;
}

.orders-table .total-column,
.orders-table .total-cell {
    background: #e7f3ff;
    font-weight: 600;
}

.orders-table .quantity-cell {
    color: #495057;
}

.missing-orders {
    background: #fff3cd;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid #ffeeba;
}

.missing-orders h3 {
    color: #856404;
    margin-bottom: 1rem;
}

.missing-orders-list {
    list-style: none;
}

.missing-orders-list li {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: #fff;
    border-radius: 0.375rem;
}

/* Template editor */
.template-form {
    background: #fff;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.info-box {
    background: #e7f3ff;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #b8daff;
}

.info-box h3 {
    color: #004085;
    margin-bottom: 0.5rem;
}

.info-box ul {
    margin-left: 1.5rem;
}

.info-box code {
    background: #fff;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
    color: #e83e8c;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .xpage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .food-item {
        flex-direction: column;
        align-items: stretch;
    }

    .quantity-control {
        justify-content: center;
    }

    .orders-table {
        font-size: 0.85rem;
    }

    .orders-table th,
    .orders-table td {
        padding: 0.5rem 0.25rem;
    }
}

@media (max-width: 480px) {
    .xbtn {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    #loginForm {
        flex-direction: column;
    }

    .dashboard-actions {
        flex-direction: column;
    }
}
