:root {
    --primary: #EA580C;
    /* Dark Orange */
    --primary-hover: #C2410C;
    --secondary: #10B981;
    /* Emerald */
    --accent: #F59E0B;
    /* Amber */
    --danger: #EF4444;
    /* Red */
    --bg-app: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius: 12px;
}

html {
    font-size: 12px;
    /* Aggressive scale down to ~75% */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding-bottom: 2rem;
}

.app-container {
    width: 100%;
    /* Full width up to max */
    max-width: 1200px;
    /* strict cap */
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Header */
.main-header {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.logo {
    display: flex;
    justify-content: center;
    width: 100%;
}

.logo img {
    display: block;
    height: 64px;
    width: auto;
}

.main-header h1 {
    font-size: 1.5rem;
    /* rems will now be smaller relative to px */
    font-weight: 700;
    color: var(--primary);
}

/* Layout */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    /* Reduced sidebar width */
    gap: 1.5rem;
    align-items: start;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* Data Entry Form */
.data-entry-panel h2 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
}

/* Removed .form-row as we are now vertical */

.form-group {
    margin-bottom: 1rem;
    width: 100%;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.6rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn-inline {
    width: auto;
    padding: 0.45rem 0.85rem;
}

.btn.primary {
    background: #FFEDD5;
    color: #9A3412;
}

.btn.primary:hover {
    background: #FED7AA;
}

.btn.secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

/* Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Schedule View */
.schedule-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 1rem;
}

.print-logo {
    display: none;
}

.print-logo img {
    display: block;
    height: 48px;
    width: auto;
}

/* Editable Title */
#schedule-title {
    border: 1px dashed transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    cursor: text;
    align-items: center;
    justify-self: center;
    text-align: center;
}

.view-controls {
    justify-self: end;
}

.schedule-header-actions {
    justify-self: start;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#schedule-title:hover,
#schedule-title:focus {
    border-color: var(--primary);
    background-color: #fef3c7;
    outline: none;
}

.weekly-grid-container {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.time-column {
    width: 70px;
    /* Reduced width */
    border-right: 1px solid var(--border);
    background: #f9fafb;
    flex-shrink: 0;
}

.time-header {
    height: 40px;
    /* Reduced height */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: #f3f4f6;
    font-size: 0.8rem;
}

/* Detailed Time Slots */
.time-slot {
    /* height will be set by JS via style */
    border-bottom: 1px solid var(--border);
    position: relative;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.time-marker-main {
    position: absolute;
    top: 0;
    left: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1;
    transform: translateY(-50%);
    /* Center on the line */
    background: #f9fafb;
    /* Mask line */
    padding-right: 2px;
}

.time-marker-sub {
    position: absolute;
    left: 8px;
    font-size: 0.65rem;
    color: #9CA3AF;
    line-height: 1;
    transform: translateY(-50%);
}


.days-grid {
    flex: 1;
    display: flex;
}

.day-column {
    flex: 1;
    border-right: 1px solid var(--border);
    min-width: 140px;
    position: relative;
    background-color: white;
}

.day-column:last-child {
    border-right: none;
}

.day-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
    color: var(--text-main);
    letter-spacing: 0.02em;
}

#day-selection label {
    font-weight: 700;
}

.day-content {
    position: relative;
    height: 540px;
    /* 12 hours * 45px */
    /* Grid Lines: SVG Background for performance and precision */
    /* Hour Line (Solid) at 0px, Half-Hour (Dashed) at 22.5px */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='45' viewBox='0 0 100 45'%3E%3Cpath d='M0 0H100' stroke='%23E5E7EB' stroke-width='1'/%3E%3Cpath d='M0 22.5H100' stroke='%23F3F4F6' stroke-width='1' stroke-dasharray='5,5'/%3E%3C/svg%3E");
    background-size: 100px 45px;
    /* Width pattern repeats, Height specific to slot */
}

/* Session Cards */
.session-card {
    position: absolute;
    left: 4px;
    right: 4px;
    padding: 6px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-main);
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Softer border */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    z-index: 10;
    border-left: 4px solid transparent;
    transition: transform 0.1s, box-shadow 0.1s;
}

.session-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 20;
}

.session-card .time {
    font-weight: 600;
    letter-spacing: -0.01em;
    opacity: 0.9;
}

.session-card .client {
    font-weight: 700;
    margin-top: 2px;
}

.session-card .rbt {
    font-style: italic;
    color: inherit;
    opacity: 0.9;
}

.session-card .location {
    font-size: 0.7rem;
    opacity: 0.88;
}

.session-card .duration {
    opacity: 0.82;
    margin-top: 4px;
}

.session-card.is-cover::after {
    content: '★';
    position: absolute;
    top: 4px;
    right: 4px;
    color: #F59E0B;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Color Palette */
.color-picker-container {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-top: 0.5rem;
}

.palette-grid {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.selected {
    border-color: #000;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.custom-color-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

#client-color {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
}

#client-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

#client-color::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

#client-color::-moz-color-swatch {
    border: none;
    border-radius: 2px;
}

.small-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* View Toggle */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #F9FAFB;
}

.view-toggle-btn {
    padding: 0.4rem 1rem;
    border: none;
    background: transparent;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-toggle-btn:first-child {
    border-right: 1px solid var(--border);
}

.view-toggle-btn:hover:not(.active) {
    background: #F3F4F6;
    color: var(--text-main);
}

.view-toggle-btn.active {
    background: #FFEDD5;
    color: #9A3412;
    font-weight: 700;
}

/* Board View */
.board-view-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.board-grid {
    display: flex;
}

.board-day-column {
    flex: 1;
    border-right: 1px solid var(--border);
    min-width: 0;
}

.board-day-column:last-child {
    border-right: none;
}

.board-day-header {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
    color: var(--text-main);
    letter-spacing: 0.02em;
}

.board-day-cards {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
}

.board-card {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    line-height: 1.4;
}

.board-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.board-card .board-card-rbt {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1.2;
}

.board-card .board-card-details {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.board-card .board-card-time {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.85;
}

.board-card .board-card-name {
    font-size: 0.8rem;
    font-weight: 600;
}

.board-card.is-cover::after {
    content: '★';
    float: right;
    color: #F59E0B;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Mobile Toggle Button */
.mobile-toggle-btn {
    display: none;
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    background: #FFEDD5;
    color: #9A3412;
    text-align: center;
    transition: background 0.2s;
}

.mobile-toggle-btn:hover {
    background: #FED7AA;
}

/* Responsive: Tablet (768px and below) */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .app-container {
        margin-top: 0.5rem;
        padding: 0 0.5rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .data-entry-panel {
        order: 2;
    }

    .schedule-view {
        order: 1;
    }

    .mobile-toggle-btn {
        display: block;
        order: 0;
    }

    .data-entry-panel.mobile-hidden {
        display: none;
    }

    .main-header {
        padding: 0.75rem 1rem;
    }

    .main-header h1 {
        font-size: 1.25rem;
    }

    .logo img {
        height: 52px;
    }

    .weekly-grid-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .day-column {
        min-width: 120px;
    }

    .schedule-header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    #schedule-title {
        justify-self: flex-start;
        text-align: left;
    }

    .view-controls {
        width: 100%;
    }

    .view-toggle {
        width: 100%;
    }

    .view-toggle-btn {
        flex: 1;
        text-align: center;
    }

    .board-day-column {
        min-width: 80px;
    }

    .board-view-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .schedule-header-actions {
        width: 100%;
    }

    .schedule-header-actions .btn-inline {
        width: auto;
    }
}

/* Responsive: Phone (480px and below) */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }

    .app-container {
        padding: 0 0.25rem;
    }

    .main-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
        text-align: center;
    }

    .logo {
        display: flex;
        justify-content: center;
    }

    .header-controls {
        display: flex;
        justify-content: center;
    }

    .card {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .day-column {
        min-width: 100px;
    }

    .time-column {
        width: 55px;
    }

    .time-marker-main {
        font-size: 0.7rem;
    }

    .time-marker-sub {
        font-size: 0.55rem;
    }

    .day-header {
        font-size: 0.75rem;
        height: 35px;
    }

    .time-header {
        height: 35px;
        font-size: 0.7rem;
    }

    .session-card {
        padding: 4px;
        font-size: 0.7rem;
        left: 2px;
        right: 2px;
    }

    .color-picker-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .color-swatch {
        width: 28px;
        height: 28px;
    }

    #total-hours-footer {
        font-size: 0.95rem !important;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .app-container {
        padding: 0;
        max-width: 100%;
    }

    .main-header,
    .data-entry-panel,
    .view-controls,
    .view-toggle,
    .mobile-toggle-btn {
        display: none !important;
    }

    #export-btn {
        display: none !important;
    }

    #download-image-btn {
        display: none !important;
    }

    .print-logo {
        display: block;
        margin-bottom: 0.5rem;
    }

    .main-content {
        display: block;
    }

    .schedule-view.card {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .weekly-grid-container {
        border: 1px solid #000;
    }

    .time-column,
    .day-column,
    .time-slot,
    .day-header {
        border-color: #000 !important;
    }

    .session-card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .day-content {
        background-color: #fff;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='45' viewBox='0 0 100 45'%3E%3Cpath d='M0 0H100' stroke='%23000' stroke-width='1'/%3E%3Cpath d='M0 22.5H100' stroke='%239CA3AF' stroke-width='0.8' stroke-dasharray='4,4'/%3E%3C/svg%3E");
        background-size: 100px 45px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
