/* =========================================================
   HASH.io CORE MECHANICS (STYLE.CSS)
   ========================================================= */

/* --- WORKSPACE & FIELD CONTAINERS --- */
#main-workspace { display: flex; gap: 20px; align-items: flex-start; justify-content: center; width: 100%; }

#field-window { 
    width: 800px; height: 550px; background-color: white; 
    border: 2px solid black; position: relative; overflow: hidden; flex-shrink: 0;
}

#zoom-container {
    width: 100%; height: 100%; position: relative;
    transform-origin: center 60%; transition: transform 0.3s ease;
}

/* --- THE TURF & MARKINGS --- */
.fadeable, .yard-number, .major-line, .tick-strip, .field-surface { transition: opacity 0.3s ease; }

#field-window.tight-view .fadeable,
#field-window.tight-view .yard-number,
#field-window.tight-view .major-line,
#field-window.tight-view .tick-strip,
#field-window.tight-view .field-surface { 
    opacity: 0; 
    pointer-events: none; 
}

.field-surface {
    position: absolute; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='75'%3E%3Crect y='73' width='10' height='2' fill='%23e0e0e0'/%3E%3C/svg%3E");
    background-repeat: repeat; z-index: 0;
}

.tick-strip { 
    position: absolute; top: 0; bottom: 0; width: 8px; z-index: 1; 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='15'%3E%3Crect y='13' width='10' height='2' fill='%23888888'/%3E%3C/svg%3E");
    background-repeat: repeat;
}
.tick-sideline-left { left: 0; }
.tick-sideline-right { right: 0; }
.tick-hash-left { left: calc(33.33% - 4px); }
.tick-hash-right { left: calc(66.66% - 4px); }

.major-line { position: absolute; left: 0; right: 0; height: 3px; background-color: #ccc; z-index: 0; }

.yard-number { 
    position: absolute; color: #ccc; font-size: 28px; font-weight: bold; 
    font-family: 'Courier New', Courier, monospace; z-index: 0; 
    line-height: 28px; text-align: center; width: 40px; margin-top: -14px; 
    pointer-events: none !important; user-select: none !important;    
    font-family: "Arial Black", Impact, sans-serif !important; 
    letter-spacing: 8px !important; 
}
.num-left { left: 110px; transform: rotate(90deg); }
.num-right { right: 110px; transform: rotate(-90deg); }

.los { position: absolute; top: 300px; left: 0; right: 0; height: 0; border-top: 2px solid #0052cc; z-index: 1;}

/* --- VISIBILITY TOGGLES --- */
#field-window.hide-offense .player.offense,
#field-window.hide-offense .route-group[data-owner^="p-"] { opacity: 0 !important; pointer-events: none !important; }
#field-window.hide-offense mask #mask-elements circle[id^="mask-p-"],
#field-window.hide-offense mask #mask-elements ellipse[id^="mask-p-"] { display: none; }

#field-window.hide-defense .player.defense,
#field-window.hide-defense .route-group[data-owner^="d-"] { opacity: 0 !important; pointer-events: none !important; }
#field-window.hide-defense mask #mask-elements circle[id^="mask-d-"],
#field-window.hide-defense mask #mask-elements ellipse[id^="mask-d-"] { display: none; }

/* --- ROUTES & ZONES --- */
#zone-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.zone-hitbox { pointer-events: all; cursor: move; }
.zone-group:hover .visible-zone { filter: brightness(0.8); }

#drawing-layer { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    pointer-events: none; z-index: 2; mask: url(#player-halo-mask);
}

.route-line.visible {
    fill: none; stroke-linejoin: round; stroke-linecap: round;
    pointer-events: none; transition: stroke 0.2s;
}

.route-group:hover .route-line.visible { filter: drop-shadow(0px 0px 3px #d32f2f); } 
.route-group:hover .route-endpoint { fill: rgba(211, 47, 47, 0.4); stroke: #d32f2f; stroke-width: 1px;}
#field-window.tight-view .route-line.visible { stroke-width: 1.0416; }

/* --- PLAYERS --- */
.player { 
    font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; 
    font-weight: bold; position: absolute; cursor: move; user-select: none; 
    z-index: 3; box-sizing: border-box; line-height: 1; letter-spacing: 0px; text-align: center; white-space: nowrap;
}
.player:hover { cursor: move; }
.player:active { cursor: move; }

/* --- TEXT BOXES --- */
.text-box {
    position: absolute; cursor: grab; z-index: 4; border: 1px dashed transparent; 
    user-select: none; font-family: Arial, sans-serif; white-space: pre-wrap; border-radius: 4px;
    word-wrap: break-word; line-height: 1.2;
}
.text-box:hover { border: 1px dashed #aaa; }
.text-box:active { cursor: grabbing; }

/* --- DRAWING MODE CURSOR --- */
body.drawing-mode, body.drawing-mode .player, body.drawing-mode #zoom-container {
    cursor: crosshair !important;
}

/* =========================================================
   PLAYBOOK PAGE BUILDER STYLES
   ========================================================= */

.pb-grid { flex: 1; width: 100%; display: grid; gap: 15px; min-height: 0; }
.pb-grid.layout-1 { display: flex; flex-direction: column; gap: 15px; }
.pb-grid.layout-2 { display: flex; flex-direction: column; gap: 15px; }
.pb-grid.layout-2-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; align-items: start; flex: none; }
.pb-grid.layout-6 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 10px;}
.pb-grid.layout-8 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr 1fr 1fr; gap: 8px; }

.pb-slot { display: flex; flex-direction: column; border: 1px solid #ccc; background: #fff; overflow: hidden; }

.pb-header {
    width: 100%; border: none; border-bottom: 1px solid #ccc; font-size: 16px; font-weight: bold;
    padding-top: 12px; padding-bottom: 6px; height: 42px; line-height: 1.5; text-align: center;
    background: #f9f9f9; box-sizing: border-box; outline: none; white-space: nowrap; overflow: hidden;
}

.pb-header:empty::before, .page-title-input:empty::before { content: attr(placeholder); color: #aaa; pointer-events: none; display: block; }

.pb-diagram {
    flex-shrink: 0; width: 100%; min-height: 100px; background: #fafafa;
    display: flex; justify-content: center; align-items: center; position: relative;
    cursor: pointer; border-bottom: 1px solid #ccc; overflow: hidden; 
}
.pb-grid.layout-8 .pb-diagram { border-bottom: none; }

.pb-diagram:hover::after {
    content: "Click to edit diagram"; position: absolute; top: 5px; right: 5px;
    background: rgba(0,0,0,0.7); color: white; padding: 4px 8px; border-radius: 4px;
    font-size: 12px; pointer-events: none; z-index: 10;
}

.pb-notes {
    width: 100%; flex: 1; border: none; padding: 8px; font-family: Arial, sans-serif; font-size: 13px;
    box-sizing: border-box; white-space: pre-wrap; word-wrap: break-word; outline: none; line-height: 1.3; 
}
.pb-grid.layout-8 .pb-notes { display: none; }

.pb-grid.layout-1 .pb-slot { border: none; }
.pb-grid.layout-1 .pb-header { font-size: 24px; padding-top: 14px; padding-bottom: 10px; height: 55px; background: #eee; border: 1px solid #ccc; border-bottom: none;}
.pb-grid.layout-1 .pb-diagram { border: 1px solid #ccc; border-bottom: 1px solid #ccc; }

.pb-notes-area { display: flex; gap: 15px; flex: 1; margin-top: 10px; padding-bottom: 10px; }
.pb-notes-main { flex: 2; border: 1px solid #ccc; min-height: 80px; padding: 8px; border-radius: 4px; font-size: 13px;}
.pb-notes-side { flex: 1; display: flex; flex-direction: column; gap: 3px; } 

.pb-grid.layout-1 .pb-notes-area { flex-direction: row; gap: 15px; }
.pb-grid.layout-1 .pb-notes-main { flex: 2; }
.pb-grid.layout-1 .pb-notes-side { flex: 1; }

.assignment-row { display: flex; border: 1px solid #ccc; background: white; border-radius: 4px; overflow: hidden; align-items: stretch; min-height: 25px;}
.assignment-pos { 
    width: 40px; border: none; border-right: 1px solid #ccc; font-weight: bold; font-size: 12px; text-align: center;
    cursor: pointer; user-select: none; flex-shrink: 0; padding: 0; margin: 0;
}
.assignment-text { flex: 1; border: none; padding: 4px 6px; font-size: 13px; font-family: Arial, sans-serif; min-height: 20px; outline: none; }
.remove-row-btn { background: #fce4e4; color: #d32f2f; border: none; border-left: 1px solid #ccc; cursor: pointer; padding: 0 10px; font-weight: bold;}
.remove-row-btn:hover { background: #f8caca; }
.add-row-btn { background: #e3f2fd; color: #1976d2; border: 1px dashed #1976d2; padding: 6px; cursor: pointer; font-weight: bold; border-radius: 4px; margin-top: 3px; font-size: 12px;}
.add-row-btn:hover { background: #bbdefb; }

.layout-title-container {
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    height: 100%; text-align: center; gap: 20px; padding: 20px; box-sizing: border-box;
}
.title-logo-box {
    width: 250px; height: 250px; border: 2px dashed #ccc; display: flex; 
    align-items: center; justify-content: center; cursor: pointer; background: #fafafa; border-radius: 12px;
}
.title-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

.title-main-text {
    font-size: 60px; font-weight: bold; width: 100%; text-align: center; 
    border: none; outline: none; font-family: Arial, sans-serif; color: #111; line-height: 1.4; padding-top: 20px; 
}
.title-sub-text {
    font-size: 28px; color: #666; width: 100%; text-align: center; 
    border: none; outline: none; font-family: Arial, sans-serif; line-height: 1.4; padding-top: 15px; 
}

/* EXPORTING STATE */
.playbook-page.exporting .logo-container, .playbook-page.exporting .title-logo-box { border: none !important; background: transparent !important; }
.playbook-page.exporting #page-logo-placeholder, .playbook-page.exporting #title-logo-placeholder { display: none !important; }
.playbook-page.exporting .pb-header { border-bottom: 1px solid #ccc !important; }
.playbook-page.exporting .remove-row-btn, .playbook-page.exporting .add-row-btn { display: none !important; }
.playbook-page.exporting [contenteditable]:empty::before { content: ""; }
.playbook-page.exporting input::placeholder { color: transparent; }
.playbook-page.exporting .pb-diagram::after { display: none !important; }


/* =========================================================
   ASSEMBLER (HOME DASHBOARD) STYLES
   ========================================================= */
.assembler-container { display: flex; gap: 20px; width: 100%; max-width: 1450px; height: 600px; margin-top: 10px; }
.playbooks-sidebar { width: 320px; background: white; border: 2px solid black; display: flex; flex-direction: column; flex-shrink: 0; }
.playbooks-sidebar h3 { margin: 0; padding: 15px; background: #e0e0e0; border-bottom: 2px solid black; font-size: 18px; text-align: center; }
.playbooks-list { flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 10px; background: #f9f9f9; }
.playbook-card { border: 1px solid #ccc; padding: 15px; background: white; border-radius: 6px; cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.playbook-card:hover { background: #e3f2fd; border-color: #1976d2; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.playbook-card.active { background: #1976d2; color: white; border-color: #1565c0; box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.playbook-card.active p { color: #e3f2fd; }
.playbook-card h4 { margin: 0 0 5px 0; font-size: 16px;}
.playbook-card p { margin: 0; font-size: 12px; color: #666;}

.playbook-editor { flex: 1; background: white; border: 2px solid black; display: flex; flex-direction: column; padding: 20px; box-sizing: border-box; }
.playbook-editor-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #ccc; padding-bottom: 15px; margin-bottom: 15px; }
.playbook-editor-header input { font-size: 28px; font-weight: bold; border: none; border-bottom: 2px dashed transparent; outline: none; width: 60%; transition: 0.2s; padding: 5px; }
.playbook-editor-header input:hover, .playbook-editor-header input:focus { border-bottom: 2px dashed #1976d2; background: #f9f9f9;}

.pb-pages-container { flex: 1; display: flex; flex-direction: column; min-height: 0;}
.pb-pages-list { flex: 1; border: 1px dashed #ccc; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: #fafafa; }

/* DRAG AND DROP STYLES */
.page-row { 
    display: flex; justify-content: space-between; align-items: center; background: white; border: 1px solid #ccc; padding: 12px 15px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: grab; transition: transform 0.2s, box-shadow 0.2s;
}
.page-row:active { cursor: grabbing; }
.page-row.dragging { opacity: 0.4; background: #e3f2fd; border: 2px dashed #1976d2; transform: scale(0.98); }
.drag-handle { color: #aaa; font-size: 20px; margin-right: 15px; cursor: grab; user-select: none; }
.page-row.drag-over-top { border-top: 3px solid #1976d2; }
.page-row.drag-over-bottom { border-bottom: 3px solid #1976d2; }

.page-row h4 { margin: 0; color: #1976d2; font-size: 16px;}
.page-row p { margin: 4px 0 0 0; font-size: 12px; color: #666;}
.page-actions { display: flex; gap: 5px; }

.empty-state { text-align: center; color: #888; font-style: italic; margin-top: 40px; }

.page-number-overlay {
    position: absolute; bottom: 20px; left: 0; right: 0; text-align: center;
    font-size: 14px; font-family: Arial, sans-serif; color: #333; z-index: 100;
    cursor: pointer; transition: opacity 0.2s ease, color 0.2s ease;
}
.page-number-overlay:hover { opacity: 0.6; color: #d32f2f; }

/* =========================================================
   LIBRARY & FOLDER UI (ULTRA-COMPACT)
   ========================================================= */
#play-library { width: 260px; height: 100%; background: #0A192F; border: 2px solid #1E293B; display: flex; flex-direction: column; flex-shrink: 0; border-radius: 12px; overflow: hidden; }
#library-list, #page-library-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }

.folder-header { 
    background: #1E293B; color: #0EA5E9; padding: 6px 10px; font-weight: 800; cursor: pointer; 
    display: flex; justify-content: space-between; align-items: center; border-radius: 4px; font-size: 11px; text-transform: uppercase; user-select: none;
}
.folder-header:hover { background: #334155; }

.folder-content { display: flex; flex-direction: column; gap: 2px; padding-left: 8px; margin-top: 2px; border-left: 1px solid #334155; margin-left: 5px; }
.folder-content.hidden { display: none !important; }

.subfolder-header { 
    background: transparent; color: #94A3B8; padding: 4px 8px; font-weight: 700; cursor: pointer; 
    display: flex; justify-content: space-between; align-items: center; font-size: 10px; text-transform: uppercase; user-select: none;
}
.subfolder-header:hover { color: #FFFFFF; }

.subfolder-content { display: flex; flex-direction: column; gap: 2px; padding-left: 10px; margin-top: 2px; border-left: 1px dashed #334155; margin-left: 5px; }
.subfolder-content.hidden { display: none !important; }

.library-item { 
    background: #112240; border: 1px solid #1E293B; padding: 6px 8px; border-radius: 4px; cursor: pointer; transition: 0.1s; 
}
.library-item:hover { border-color: #00BFA5; background: #1E293B; }
.library-item.active { background: #00BFA5; border-color: #00BFA5; }

.library-item h4 { margin: 0 0 2px 0; color: #F8FAFC; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-item.active h4 { color: #0A192F; }

.library-item p { margin: 0; font-size: 9.5px; color: #94A3B8; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-item.active p { color: #0A192F; font-weight: 600; }