/* ==========================================================
   BASE
   ========================================================== */

* {
    box-sizing: border-box;
}


html {
    margin: 0;
    padding: 0;
}


body {
    margin: 0;
    padding: 0;

    background: #f3f5f7;
    color: #1f2937;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
}


button,
input,
select {
    font: inherit;
}


/* ==========================================================
   PAGE
   ========================================================== */

.page {
    width: 100%;
    max-width: 1100px;

    margin: 0 auto;

    padding: 24px;
}


/* ==========================================================
   HEADER
   ========================================================== */

.header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 20px;

    margin-bottom: 24px;
}


.header h1 {
    margin: 0;

    font-size: 30px;
    line-height: 1.2;
}


.subtitle {
    margin: 5px 0 0;

    color: #6b7280;
}


.logout-button {
    display: inline-block;

    padding: 9px 15px;

    border-radius: 7px;

    background: #374151;
    color: white;

    text-decoration: none;

    font-weight: 600;
}


.logout-button:hover {
    background: #1f2937;
}


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

.card {
    margin-bottom: 22px;

    padding: 22px;

    background: white;

    border: 1px solid #dfe3e8;

    border-radius: 12px;

    box-shadow:
        0 2px 6px
        rgba(0, 0, 0, 0.04);
}


.card h2 {
    margin-top: 0;
    margin-bottom: 8px;

    font-size: 21px;
}


.section-header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 12px;
}


.help-text {
    margin-top: 5px;
    margin-bottom: 18px;

    color: #6b7280;

    line-height: 1.45;
}


/* ==========================================================
   FORM
   ========================================================== */

.form-row {
    display: flex;

    flex-wrap: wrap;

    gap: 15px;

    margin-bottom: 15px;
}


.schedule-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 15px;

    margin-bottom: 18px;
}


.form-group {
    display: flex;
    flex-direction: column;

    gap: 6px;
}


.form-group label {
    font-weight: 600;
    font-size: 14px;
}


input,
select {
    width: 100%;

    min-height: 42px;

    padding: 9px 11px;

    border:
        1px solid #cbd5e1;

    border-radius: 7px;

    background: white;

    color: #111827;
}


input:focus,
select:focus {
    outline: none;

    border-color: #64748b;

    box-shadow:
        0 0 0 2px
        rgba(100, 116, 139, 0.15);
}


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

button {
    border: 0;

    border-radius: 7px;

    padding: 10px 16px;

    cursor: pointer;

    font-weight: 650;

    transition:
        opacity 0.15s,
        transform 0.05s;
}


button:hover {
    opacity: 0.9;
}


button:active {
    transform: translateY(1px);
}


.primary-button {
    background: #2563eb;
    color: white;
}


.secondary-button {
    background: #e5e7eb;
    color: #111827;
}


.action-buttons {
    display: flex;

    flex-wrap: wrap;

    gap: 10px;

    margin-top: 8px;
}


.travel-button {
    background: #2563eb;
    color: white;
}


.labor-button {
    background: #059669;
    color: white;
}


.finish-button {
    background: #dc2626;
    color: white;
}


.delete-button {
    padding: 6px 10px;

    background: #fee2e2;

    color: #991b1b;
}


/* ==========================================================
   STATUS
   ========================================================== */

.status-badge {
    display: inline-block;

    margin:
        6px 0 12px;

    padding:
        6px 11px;

    border-radius: 999px;

    font-size: 13px;

    font-weight: 700;
}


.status-loading {
    background: #e5e7eb;
    color: #374151;
}


.status-online {
    background: #d1fae5;
    color: #065f46;
}


.status-offline {
    background: #fee2e2;
    color: #991b1b;
}


/* ==========================================================
   PRE OUTPUT
   ========================================================== */

pre {
    max-width: 100%;

    overflow-x: auto;

    padding: 14px;

    background: #111827;
    color: #e5e7eb;

    border-radius: 8px;

    white-space: pre-wrap;
    word-break: break-word;

    font-size: 13px;
    line-height: 1.4;
}


/* ==========================================================
   MESSAGES
   ========================================================== */

.message-box {
    margin-top: 14px;

    padding: 10px 12px;

    border-radius: 7px;

    font-weight: 600;
}


.message-success {
    background: #d1fae5;
    color: #065f46;
}


.message-error {
    background: #fee2e2;
    color: #991b1b;
}


.hidden {
    display: none;
}


/* ==========================================================
   TABLE
   ========================================================== */

.table-wrapper {
    overflow-x: auto;
}


table {
    width: 100%;

    border-collapse: collapse;

    margin-top: 10px;
}


th,
td {
    padding: 11px 10px;

    text-align: left;

    border-bottom:
        1px solid #e5e7eb;

    white-space: nowrap;
}


th {
    background: #f8fafc;

    color: #475569;

    font-size: 13px;
}


.activity-cell {
    text-transform: uppercase;

    font-weight: 650;
}


.task-status {
    display: inline-block;

    padding: 4px 8px;

    border-radius: 999px;

    font-size: 12px;

    font-weight: 700;

    text-transform: uppercase;
}


.status-scheduled {
    background: #dbeafe;
    color: #1e40af;
}


.status-running {
    background: #fef3c7;
    color: #92400e;
}


.status-completed {
    background: #d1fae5;
    color: #065f46;
}


.status-failed {
    background: #fee2e2;
    color: #991b1b;
}


/* ==========================================================
   REMOTE PIXEL CONTROL
   ========================================================== */

.remote-card {
    background: #fafafa;
}


#remotePanel summary {
    cursor: pointer;

    list-style: none;

    font-size: 20px;

    font-weight: 700;

    user-select: none;
}


#remotePanel summary::-webkit-details-marker {
    display: none;
}


#remotePanel summary::before {
    content: "▶";

    display: inline-block;

    margin-right: 9px;

    font-size: 13px;

    transition:
        transform 0.15s;
}


#remotePanel[open] summary::before {
    transform: rotate(90deg);
}


.optional-label {
    display: inline-block;

    margin-left: 8px;

    padding: 3px 7px;

    border-radius: 999px;

    background: #e5e7eb;

    color: #6b7280;

    font-size: 11px;

    vertical-align: middle;
}


.remote-content {
    margin-top: 18px;
}


.remote-toolbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 10px;

    margin-bottom: 12px;
}


.remote-status {
    display: inline-block;

    padding: 5px 10px;

    border-radius: 999px;

    background: #e5e7eb;

    color: #374151;

    font-size: 13px;

    font-weight: 650;
}


.remote-loading {
    background: #fef3c7;
    color: #92400e;
}


.remote-online {
    background: #d1fae5;
    color: #065f46;
}


.remote-error {
    background: #fee2e2;
    color: #991b1b;
}


/* ==========================================================
   PHONE FRAME
   ========================================================== */

.phone-frame {
    width: 100%;

    max-width: 430px;

    margin:
        0 auto;

    padding: 8px;

    background: #111827;

    border-radius: 18px;

    min-height: 100px;
}


#pixelScreen {
    display: block;

    width: 100%;
    height: auto;

    margin: 0;

    border-radius: 11px;

    background: black;

    cursor: crosshair;

    touch-action: none;

    user-select: none;

    -webkit-user-select: none;

    -webkit-user-drag: none;
}


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

.phone-buttons {
    display: grid;

    grid-template-columns:
        repeat(
            5,
            minmax(0, 1fr)
        );

    gap: 8px;

    max-width: 650px;

    margin:
        12px auto 0;
}


.phone-buttons button {
    padding: 10px 5px;

    background: #374151;

    color: white;

    font-size: 13px;
}


/* ==========================================================
   MOBILE
   ========================================================== */

@media (
    max-width: 760px
) {

    .page {
        padding: 12px;
    }


    .header {
        align-items: flex-start;
    }


    .header h1 {
        font-size: 24px;
    }


    .card {
        padding: 16px;
    }


    .schedule-grid {
        grid-template-columns: 1fr;
    }


    .action-buttons {
        display: grid;

        grid-template-columns: 1fr;
    }


    .action-buttons button {
        width: 100%;
    }


    .phone-buttons {
        grid-template-columns:
            repeat(
                3,
                minmax(0, 1fr)
            );
    }


    th,
    td {
        padding: 9px 7px;

        font-size: 13px;
    }
}


@media (
    max-width: 480px
) {

    .header {
        flex-direction: column;
    }


    .logout-button {
        width: 100%;

        text-align: center;
    }


    .phone-buttons {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }


    .remote-toolbar {
        align-items: stretch;

        flex-direction: column;
    }
}
