/* ===================================================================
   main.css  –  Global resets, CSS custom properties, layout skeleton
   =================================================================== */

/* ------------------------------------------------------------------ */
/*  Design tokens                                                       */
/* ------------------------------------------------------------------ */
:root {
    /* Surfaces */
    --bg-app:       #1e1e1e;
    --bg-toolbar:   #252525;
    --bg-ribbon:    #2d2d2d;
    --bg-panel:     #2d2d2d;
    --bg-workspace: #3b3b3b;
    --bg-statusbar: #1a1a1a;

    /* Borders */
    --border-color: #404040;
    --border-light: #4a4a4a;

    /* Text */
    --text-primary:   #d4d4d4;
    --text-secondary: #9d9d9d;
    --text-muted:     #666666;
    --text-accent:    #4fc3f7;

    /* Interactive */
    --hover-bg:   #3a3a3a;
    --active-bg:  #0078d4;
    --active-tab: #007acc;
    --focus-ring: #0078d4;

    /* Canvas */
    --canvas-bg:   #3b3b3b;
    --grid-dot:    #5d5d5d;
    --grid-origin: #555555;

    /* Dimensions */
    --ribbon-height:    86px;
    --toolbar-width:    44px;
    --statusbar-height: 24px;
    --tab-height:       28px;
    --ribbon-body-height: 74px;

    /* Floating panels / popups */
    --panel-bg:             #1e1e1e;
    --panel-bg-header:      #252526;
    --panel-text-primary:   #d4d4d4;
    --panel-text-secondary: #9d9d9d;
    --panel-text-muted:     #666666;

    /* Typography */
    --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
    --fs-xs:  10px;
    --fs-sm:  11px;
    --fs-md:  12px;
    --fs-lg:  13px;
}

/* ------------------------------------------------------------------ */
/*  Reset                                                               */
/* ------------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    padding: 0;
}

button:focus-visible {
    outline: 1px solid var(--focus-ring);
    outline-offset: -1px;
}

input, select {
    font-family: inherit;
    font-size: inherit;
}

/* ------------------------------------------------------------------ */
/*  Application shell                                                   */
/* ------------------------------------------------------------------ */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* The title bar row above the ribbon tabs */
#title-bar {
    display: flex;
    align-items: stretch;
    height: 30px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
}

/* Tab bar — fills the title bar */
#tab-bar {
    display: flex;
    align-items: flex-end;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;      /* Firefox */
    padding: 0 4px;
    gap: 2px;
}
#tab-bar::-webkit-scrollbar { display: none; }

/* Individual file tab */
.file-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 8px 0 10px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    max-width: 180px;
    white-space: nowrap;
    transition: background 0.1s, color 0.1s;
    position: relative;
}
.file-tab:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.file-tab.active {
    background: var(--bg-workspace, #1e1e1e);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Filename label inside tab */
.ft-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Unsaved-changes dot */
.ft-dot {
    font-size: 9px;
    color: var(--text-accent);
    line-height: 1;
}

/* Close button inside tab */
.ft-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    opacity: 0.5;
    transition: opacity 0.1s, background 0.1s;
}
.file-tab:hover .ft-close,
.file-tab.active .ft-close { opacity: 1; }
.ft-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* New-tab + button */
.ft-new-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    align-self: flex-end;
    transition: background 0.1s, color 0.1s;
}
.ft-new-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }

/* Inline rename input inside a tab */
.ft-rename-input {
    max-width: 160px;
    min-width: 40px;
}

#app-title {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.02em;
}

#drawing-name {
    margin-left: 12px;
    font-size: var(--fs-sm);
    color: var(--text-accent);
    cursor: text;
    border-radius: 3px;
    padding: 1px 5px;
    outline: none;
    min-width: 20px;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
}

#drawing-name:hover {
    background: rgba(255, 255, 255, 0.06);
}

#drawing-name:focus {
    background: rgba(0, 120, 212, 0.15);
    box-shadow: 0 0 0 1px rgba(79, 195, 247, 0.4);
}

/* Middle content row: left toolbar + workspace + (future right panel) */
#content-row {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ------------------------------------------------------------------ */
/*  Panel resize handles                                               */
/* ------------------------------------------------------------------ */

/* Horizontal handle – sits between rows, resizes height */
.resizer-h {
    height: 4px;
    flex-shrink: 0;
    cursor: ns-resize;
    background: var(--border-color);
    position: relative;
    z-index: 20;
    transition: background 0.12s;
}
.resizer-h:hover,
.resizer-h.dragging {
    background: var(--active-bg);
}

/* Vertical handle – sits between columns, resizes width */
.resizer-v {
    width: 4px;
    flex-shrink: 0;
    cursor: ew-resize;
    background: var(--border-color);
    position: relative;
    z-index: 20;
    transition: background 0.12s;
}
.resizer-v:hover,
.resizer-v.dragging {
    background: var(--active-bg);
}

/* ------------------------------------------------------------------ */
/*  Utility classes                                                     */
/* ------------------------------------------------------------------ */
.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------ */
/*  Notification / toast                                                */
/* ------------------------------------------------------------------ */
#notification {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f3a4f;
    color: var(--text-accent);
    border: 1px solid #2a5276;
    border-radius: 4px;
    padding: 6px 16px;
    font-size: var(--fs-sm);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
}

#notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#notification.error {
    background: #3a1f1f;
    color: #f48c8c;
    border-color: #6b2020;
}
