/* Floor Plan Photo Viewer - Dark Theme */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: #1e1e36;
    --text-primary: #e8e8f0;
    --text-secondary: #8892a4;
    --text-muted: #5a6270;
    --accent: #e53e3e;
    --accent-hover: #c53030;
    --success: #4ade80;
    --warning: #fbbf24;
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.4);
    --font: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-card); border-color: var(--text-muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: #7f1d1d; border-color: #991b1b; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------------------------------------------------------------------------
   Admin Dashboard
--------------------------------------------------------------------------- */

.dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.dashboard h1 {
    font-size: 28px;
    margin-bottom: 24px;
    font-weight: 600;
}

.case-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
}

.case-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s;
}
.case-card:hover { border-color: var(--accent); }

.case-card-info h3 { font-size: 18px; font-weight: 500; }
.case-card-info p { font-size: 13px; color: var(--text-secondary); }
.case-card-meta { font-size: 12px; color: var(--text-muted); }

/* New case form */
.new-case-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}

.new-case-form h2 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 500;
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.form-group label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group textarea {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Admin Editor
--------------------------------------------------------------------------- */

.editor-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.editor-left {
    flex: 7;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.editor-toolbar .case-title {
    font-size: 15px;
    font-weight: 500;
    margin-right: auto;
}

#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#plan-canvas {
    display: block;
    cursor: grab;
}

/* Right panel - Photo tray */
.editor-right {
    flex: 3;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-width: 280px;
    max-width: 360px;
}

.tray-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tray-header h3 { font-size: 14px; font-weight: 500; }

#photo-tray-items {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}

.tray-item {
    width: calc(50% - 4px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    cursor: grab;
    transition: border-color 0.15s, transform 0.15s;
}
.tray-item:hover { border-color: var(--success); }
.tray-item.dragging { opacity: 0.4; transform: scale(0.95); }

.tray-item img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
}

.tray-item-info {
    padding: 4px 8px 6px;
}

.tray-item-name {
    display: block;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tray-item-date {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}

.tray-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
    width: 100%;
}

/* Edit panel (overlays on right side) */
.edit-panel {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px 0 0 0;
    padding: 16px;
    z-index: 10;
    box-shadow: -4px -4px 16px var(--shadow);
}

.edit-panel.hidden { display: none; }

.edit-panel h4 {
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 500;
}

.edit-panel img {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 4px;
    margin-bottom: 8px;
    background: var(--bg-primary);
}

.edit-panel .form-group { margin-bottom: 8px; }
.edit-panel .form-group label { font-size: 11px; }
.edit-panel .form-group input,
.edit-panel .form-group textarea {
    font-size: 13px;
    padding: 6px 10px;
}

.edit-panel .btn-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* Hidden utility */
.hidden { display: none !important; }

/* File inputs (hidden) */
input[type="file"] { display: none; }

/* ---------------------------------------------------------------------------
   Viewer Login
--------------------------------------------------------------------------- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 32px;
    text-align: center;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-card .subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    text-align: center;
    margin-bottom: 16px;
}
.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
}

.login-card .error {
    color: var(--accent);
    font-size: 13px;
    margin-bottom: 12px;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 16px;
}

/* ---------------------------------------------------------------------------
   Viewer (full-screen)
--------------------------------------------------------------------------- */

.viewer-page {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

#viewer-canvas {
    display: block;
    cursor: grab;
}

/* Photo modal */
.photo-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.photo-modal.hidden { display: none; }

.modal-content {
    max-width: 900px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.modal-content img {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
    background: #000;
}

.modal-info {
    padding: 16px 20px;
}

.modal-info .date {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-info .notes {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.9); }
