/* Workspace Grid CSS - SPEC-046: 12-Column Grid Layout */

.workspace-grid-container {
    height: 100%;
    width: 100%;
    min-height: 500px;
    overflow: auto;
}

/* TimeObject Styling */
.time-object {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: var(--space-5);
    background: transparent;
}

.time-object h3 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-semibold);
    margin: 0;
    color: hsl(var(--c-text));
    font-family: var(--font-display);
}

/* =============================================================================
   SPEC-046: 12-Column Responsive Grid Layout
   Objects flow left-to-right, top-to-bottom. ColSpan controls width.
   ============================================================================= */

:root {
    --grid-columns: 12;
    --grid-gap: 16px;
    --grid-padding: 16px;
    --object-min-height: 120px;

    /* Weather gradient colors (kept from SPEC-024) */
    --c-weather-freezing-start: 240 70% 50%;
    --c-weather-freezing-end: 220 80% 40%;
    --c-weather-cold-start: 200 80% 50%;
    --c-weather-cold-end: 210 70% 45%;
    --c-weather-mild-start: 160 60% 45%;
    --c-weather-mild-end: 180 50% 40%;
    --c-weather-warm-start: 45 90% 55%;
    --c-weather-warm-end: 30 85% 50%;
    --c-weather-hot-start: 30 90% 55%;
    --c-weather-hot-end: 0 80% 50%;
}

/* Workspace Surface - 12-column grid */
.workspace-surface {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gap);
    padding: var(--grid-padding);
    width: 100%;
    min-height: 600px;
    background: hsl(var(--c-bg));
    align-content: start;
}

/* Object Panels - Card Styling */
.workspace-object-panel {
    grid-column: span var(--col-span, 3);
    min-height: var(--object-min-height);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(30,32,44,0.95) 0%, rgba(22,24,34,0.98) 100%);
    display: flex;
    flex-direction: column;
    transition: box-shadow 250ms ease-out, border-color 250ms ease-out, transform 250ms ease-out;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* Light mode panel override */
:root:not([data-theme="dark"]) .workspace-object-panel {
    background: linear-gradient(145deg, rgba(255,255,255,0.97) 0%, rgba(248,250,252,0.99) 100%);
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 2px 12px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.8);
}

/* Gradient border on hover */
.workspace-object-panel::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(45,212,191,0.3) 0%,
        transparent 50%
    );
    opacity: 0;
    transition: opacity 250ms ease-out;
    z-index: -1;
    pointer-events: none;
}

:root:not([data-theme="dark"]) .workspace-object-panel::after {
    background: linear-gradient(135deg, rgba(45,212,191,0.15) 0%, transparent 50%);
}

/* Object Panel Header */
.workspace-object-panel .panel-header {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: rgba(255,255,255,0.02);
    border-radius: 15px 15px 0 0;
    cursor: grab;
    user-select: none;
}

:root:not([data-theme="dark"]) .workspace-object-panel .panel-header {
    border-bottom-color: rgba(0,0,0,0.05);
    background: rgba(0,0,0,0.01);
}

.workspace-object-panel .panel-header:active {
    cursor: grabbing;
}

.workspace-object-panel .panel-header .drag-handle {
    color: hsl(var(--c-text-muted));
    font-size: 16px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.workspace-object-panel:hover .panel-header .drag-handle {
    opacity: 1;
}

.workspace-object-panel .panel-header h4 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    font-family: var(--font-display);
    color: hsl(var(--c-text));
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-object-panel .panel-header .delete-button {
    background: transparent;
    border: none;
    color: hsl(var(--c-text-muted));
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    transition: all 150ms ease-out;
    opacity: 0;
    font-size: var(--font-size-sm);
}

.workspace-object-panel:hover .panel-header .delete-button {
    opacity: 1;
}

.workspace-object-panel .panel-header .delete-button:hover {
    background: hsl(var(--c-danger) / 0.1);
    color: hsl(var(--c-danger));
}

/* Object Panel Content */
.workspace-object-panel .panel-content {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: var(--space-3);
    overflow: auto;
    min-height: 60px;
}

.workspace-object-panel .panel-content > * {
    width: 100%;
}

/* Object Being Dragged */
.workspace-object-panel.dragging {
    opacity: 0.4;
    transform: scale(0.95) rotate(2deg);
    box-shadow: 0 10px 30px hsl(var(--c-shadow) / 0.3);
    z-index: 1000;
}

/* Object Hover State */
.workspace-object-panel:hover {
    border-color: rgba(45,212,191,0.2);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    transform: translateY(-1px);
}

:root:not([data-theme="dark"]) .workspace-object-panel:hover {
    border-color: rgba(45,212,191,0.25);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.workspace-object-panel:hover::after {
    opacity: 1;
}

/* Drop placeholder shown during drag reorder */
.workspace-drop-placeholder {
    grid-column: span var(--col-span, 3);
    min-height: var(--object-min-height);
    border: 2px dashed hsl(var(--c-primary) / 0.6);
    border-radius: var(--card-border-radius);
    background: hsl(var(--c-primary) / 0.08);
    transition: all 150ms ease;
}

/* ============= RESIZE HANDLES ============= */

/* Base resize handle */
.workspace-object-panel .resize-handle {
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.workspace-object-panel:hover .resize-handle {
    opacity: 1;
}

/* Right-edge resize handle (ColSpan) */
.workspace-object-panel .resize-right {
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

.workspace-object-panel .resize-right::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    border-radius: 2px;
    background: hsl(var(--c-text-muted) / 0.4);
    transition: background 0.2s ease;
}

/* Left-edge resize handle (ColSpan) */
.workspace-object-panel .resize-left {
    top: 0;
    left: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
}

.workspace-object-panel .resize-left::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    border-radius: 2px;
    background: hsl(var(--c-text-muted) / 0.4);
    transition: background 0.2s ease;
}

/* Bottom-edge resize handle (height) */
.workspace-object-panel .resize-bottom {
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: row-resize;
}

.workspace-object-panel .resize-bottom::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 2px;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: hsl(var(--c-text-muted) / 0.4);
    transition: background 0.2s ease;
}

.workspace-object-panel .resize-handle:hover::before {
    background: hsl(var(--c-primary));
}

/* Resizing state */
.workspace-object-panel.resizing {
    user-select: none;
    border-color: hsl(var(--c-primary));
    z-index: 100;
}

.workspace-object-panel.resizing .resize-handle {
    opacity: 1;
}

.workspace-object-panel.resizing .resize-right::before,
.workspace-object-panel.resizing .resize-left::before {
    background: hsl(var(--c-primary));
    height: 100%;
}

.workspace-object-panel.resizing .resize-bottom::before {
    background: hsl(var(--c-primary));
    width: 100%;
}

/* ColSpan indicator shown during resize */
.colspan-indicator {
    position: absolute;
    top: -28px;
    right: 0;
    background: hsl(var(--c-primary));
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1000;
}

/* ============= RESPONSIVE BREAKPOINTS ============= */

/* Tablet: 6-column grid */
@media (max-width: 1199px) and (min-width: 768px) {
    .workspace-surface {
        grid-template-columns: repeat(6, 1fr);
    }
    /* Clamp all spans to max 6 */
    .workspace-object-panel {
        grid-column: span min(var(--col-span, 3), 6);
    }
}

/* Mobile: single column */
@media (max-width: 767px) {
    .workspace-surface {
        grid-template-columns: 1fr;
        padding: 8px;
        gap: 8px;
    }
    .workspace-object-panel {
        grid-column: span 1 !important;
    }

    .time-object h3 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .time-object h3 {
        font-size: 1.2rem;
    }

    .time-object {
        padding: 10px;
    }
}
