/* INTERSTONE Brand Variables */
:root {
    --primary: #3498DB;
    --primary-hover: #2980B9;
    --dark: #2C3E50;
    --light-bg: #F8F9FA;
    --white: #FFFFFF;
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #F44336;
    --muted: #78909C;
    --border: #E0E0E0;
    --shadow: 0 0 20px rgba(0,0,0,0.08);
}

/* Base */
body {
    font-family: Arial, sans-serif;
    background-color: var(--light-bg);
    color: #333;
}

.bg-light {
    background-color: var(--light-bg);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--dark);
}

/* Navbar */
.navbar {
    background-color: var(--dark);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-success:hover {
    background-color: #43A047;
}

.btn-secondary {
    background-color: var(--muted);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

/* Flash messages */
.flash-message {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
}

.flash-success {
    background-color: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.flash-error {
    background-color: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

/* SSE Indicator */
.sse-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.sse-connected {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.sse-disconnected {
    background-color: var(--danger);
    box-shadow: 0 0 6px var(--danger);
}

/* Counter cards */
.counter-card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    text-align: center;
    padding: 12px 8px;
    border-top: 3px solid var(--border);
}

.counter-card.counter-planned { border-top-color: var(--warning); }
.counter-card.counter-arrived { border-top-color: var(--success); }
.counter-card.counter-completed { border-top-color: #9E9E9E; }
.counter-card.counter-cancelled { border-top-color: var(--danger); }

.counter-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.counter-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Scheduler */
.scheduler-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
}

.scheduler-timeline {
    position: relative;
    min-height: 100px;
}

.time-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--light-bg);
    border-bottom: 1px solid var(--border);
}

.time-header-cell {
    flex-shrink: 0;
    width: 120px;
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    border-right: 1px solid var(--border);
}

.time-header-cell:first-child {
    width: 40px;
}

.lane-area {
    position: relative;
}

.lane-row {
    position: relative;
    height: 52px;
    border-bottom: 1px solid #f0f0f0;
}

.lane-row:nth-child(even) {
    background: rgba(0,0,0,0.01);
}

.time-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #EEEEEE;
    z-index: 1;
}

.time-grid-line.hour {
    background-color: #E0E0E0;
}

.current-time-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--danger);
    z-index: 5;
}

.current-time-marker {
    position: absolute;
    top: -6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--danger);
    transform: translateX(-3px);
}

/* Event blocks */
.event-block {
    position: absolute;
    height: 40px;
    top: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    overflow: hidden;
    white-space: nowrap;
    z-index: 3;
    transition: box-shadow 0.2s, transform 0.15s;
    border: 1px solid rgba(0,0,0,0.1);
    min-width: 30px;
}

.event-block:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px);
    z-index: 10;
}

.event-block.selected {
    box-shadow: 0 0 0 2px var(--dark), 0 4px 12px rgba(0,0,0,0.2);
    z-index: 5;
}

.event-block .event-icon {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
}

.event-block .event-label {
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 4px;
    min-width: 0;
}

/* Hide label text when block is too narrow, keep only icon */
.event-block.narrow .event-label {
    display: none;
}

/* Status colors */
.event-block.status-planned {
    background-color: var(--warning);
    color: #333;
}

.event-block.status-active_ext {
    background-color: var(--primary);
    animation: pulse 2s infinite;
}

.event-block.status-arrived {
    background-color: var(--success);
    animation: pulse 2s infinite;
}

.event-block.status-completed,
.event-block.status-completed_no_mark {
    background-color: #9E9E9E;
}

.event-block.status-cancelled {
    background-color: var(--danger);
    opacity: 0.7;
}

.event-block.status-cancelled .event-label {
    text-decoration: line-through;
}

/* Detail panel */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 13px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--muted);
    font-weight: 500;
}

.detail-value {
    color: var(--dark);
    font-weight: 500;
    text-align: right;
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.badge-planned { background: #FFF3CD; color: #856404; }
.status-badge.badge-active_ext { background: #D6EAF8; color: #1A5276; }
.status-badge.badge-arrived { background: #D5F5E3; color: #1E8449; }
.status-badge.badge-completed { background: #E0E0E0; color: #424242; }
.status-badge.badge-completed_no_mark { background: #E0E0E0; color: #424242; }
.status-badge.badge-cancelled { background: #FFCDD2; color: #B71C1C; }

/* Pulse animation */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(52, 152, 219, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 152, 219, 0); }
}

.status-arrived {
    animation-name: pulse-green;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* No events message */
.no-events {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
    font-size: 16px;
}

/* Detail action buttons */
.detail-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-actions button,
.detail-actions .btn-primary,
.detail-actions .btn-success {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

.detail-actions input,
.detail-actions textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.detail-actions textarea {
    resize: vertical;
    min-height: 60px;
}

/* Table */
table {
    border-collapse: collapse;
}

table th {
    font-weight: 600;
}

/* Unplanned events */
.event-block.unplanned {
    border: 2px solid #E65100 !important;
    background-color: #FF7043 !important;
    color: #fff !important;
}

.event-block.unplanned.status-arrived {
    background-color: #FF8C00 !important;
}

.event-block.unplanned.status-completed,
.event-block.unplanned.status-completed_no_mark {
    background-color: #BF360C !important;
    opacity: 0.85;
}

.badge-unplanned {
    display: inline-block;
    background-color: #FF7043;
    color: #fff;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 600;
}

/* btn-warning */
.btn-warning {
    background-color: #FF7043;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-warning:hover {
    background-color: #E64A19;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 420px;
    max-width: 95vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* Event hover tooltip */
.event-tooltip {
    position: fixed;
    display: none;
    z-index: 9999;
    width: 260px;
    background: #1e2330;
    color: #e8ecf4;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    padding: 12px 14px;
    font-size: 12.5px;
    pointer-events: none;
    transition: opacity 0.12s ease;
    border: 1px solid rgba(255,255,255,0.08);
}

.event-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 8px;
}

.event-tooltip .tt-row:last-child {
    border-bottom: none;
}

.event-tooltip .tt-label {
    color: #8b97b0;
    font-size: 11px;
    white-space: nowrap;
    padding-top: 1px;
    flex-shrink: 0;
    min-width: 68px;
}

.event-tooltip .tt-val {
    color: #e8ecf4;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.event-tooltip .tt-id {
    font-family: monospace;
    font-size: 11.5px;
    color: #94b8ff;
}

.event-tooltip .tt-badge-unplanned {
    display: inline-block;
    background: #FF7043;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
}

.event-tooltip .tt-status {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}

.event-tooltip .tt-status-planned      { background:#FFC107; color:#333; }
.event-tooltip .tt-status-active_ext   { background:#1976D2; color:#fff; }
.event-tooltip .tt-status-arrived      { background:#2E7D32; color:#fff; }
.event-tooltip .tt-status-completed    { background:#616161; color:#fff; }
.event-tooltip .tt-status-completed_no_mark { background:#757575; color:#fff; }
.event-tooltip .tt-status-cancelled    { background:#C62828; color:#fff; }

.tt-plate {
    display: inline-flex;
    align-items: stretch;
    background: #fff;
    color: #000;
    border: 1.5px solid #111;
    border-radius: 4px;
    overflow: hidden;
    font-family: "Helvetica Neue", Arial, sans-serif;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
    vertical-align: middle;
}
.tt-plate-main {
    padding: 3px 6px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
}
.tt-plate-region {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px 5px;
    border-left: 1.5px solid #111;
}
.tt-plate-region-num {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.tt-plate-rus {
    font-size: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 1px;
}

.counter-card.counter-unplanned { border-top-color: #FF7043; }
