:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f8fafc;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --board-bg: #f8fafc;
    --border-color: #e2e8f0;
    --postit-bg: #fef9c3;
    --postit-header-bg: #fef08a;
    --postit-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --postit-drag-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #1e293b;
    --text-muted: #64748b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f1f5f9;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* UTILITY CLASSES */
.hidden { display: none !important; }
.flex-1 { flex: 1; }

/* AUTHENTICATION SCREEN */
.auth-container {
    max-width: 420px;
    margin: 80px auto;
    padding: 32px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    position: relative;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
}

.auth-header h1 {
    font-size: 1.75rem;
    color: #1e293b;
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.override-gears-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.override-gears-btn:hover {
    background: #e2e8f0;
}

.auth-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: -2px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.readonly-input {
    background-color: #f1f5f9;
    color: #64748b;
}

.form-help {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.btn-primary {
    padding: 10px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.auth-container .btn-primary {
    width: 100%;
}

.btn-secondary {
    padding: 8px 14px;
    background-color: #475569;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background-color: #334155;
}

.btn-danger {
    padding: 8px 14px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

/* MAIN APP LAYOUT */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    background-color: var(--bg-dark);
    color: white;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.brand-icon {
    font-size: 1.5rem;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-badge {
    background: #334155;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

/* MAIN CONTAINER WITH SIDEBAR & BOARD */
.app-main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 105px);
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.btn-icon-add {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-icon-add:hover {
    background: var(--primary-hover);
}

.groups-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.group-item {
    border-radius: 6px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.2s, border-color 0.2s;
    border: 1px solid transparent;
}

.group-item.drag-over {
    background: rgba(37, 99, 235, 0.2) !important;
    border: 2px dashed #60a5fa !important;
}

.group-item.active {
    background: var(--sidebar-hover);
    border-left: 4px solid var(--primary-color);
}

.group-item-header {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.group-name-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    flex: 1;
}

.group-badge {
    background: #475569;
    color: #f1f5f9;
    font-size: 0.75rem;
    padding: 2px 7px;
    border-radius: 10px;
}

.group-actions {
    display: flex;
    gap: 4px;
    opacity: 0.7;
}

.group-item:hover .group-actions {
    opacity: 1;
}

.btn-mini {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 4px;
    color: #cbd5e1;
    border-radius: 3px;
}

.btn-mini:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* ACCORDION EXPANDED NOTES LIST */
.group-notes-accordion {
    padding: 4px 8px 8px 24px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.sidebar-note-title {
    padding: 4px 8px;
    font-size: 0.85rem;
    color: #cbd5e1;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 4px;
}

.sidebar-note-title:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-add-note-link {
    display: inline-block;
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    color: #60a5fa;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-add-note-link:hover {
    text-decoration: underline;
}

/* MAIN PANEL BOARD */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--board-bg);
    position: relative;
    overflow: hidden;
}

.main-panel-header {
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-title-container h2 {
    font-size: 1.3rem;
    color: #0f172a;
}

.group-desc-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.notes-board {
    flex: 1;
    position: relative;
    overflow: auto;
    padding: 24px;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

/* YELLOW POST-IT NOTES */
.post-it-note {
    position: absolute;
    width: 240px;
    min-height: 220px;
    background: linear-gradient(135deg, #fff7d1 0%, #fef08a 100%);
    border-radius: 4px;
    box-shadow: var(--postit-shadow);
    display: flex;
    flex-direction: column;
    padding: 0;
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.1s;
    user-select: none;
    z-index: 10;
}

.post-it-note:active {
    cursor: grabbing;
    box-shadow: var(--postit-drag-shadow);
    z-index: 100;
}

.post-it-header {
    background-color: var(--postit-header-bg);
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.post-it-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #713f12;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    padding-right: 6px;
}

.post-it-actions {
    display: flex;
    gap: 4px;
}

.post-it-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.7;
    padding: 2px 4px;
    border-radius: 3px;
}

.post-it-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.post-it-dates {
    padding: 4px 10px;
    font-size: 0.72rem;
    color: #854d0e;
    background: rgba(254, 240, 138, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.post-it-body {
    padding: 10px 12px;
    flex: 1;
    font-size: 0.88rem;
    color: #451a03;
    line-height: 1.4;
    overflow-y: auto;
    word-break: break-word;
}

.post-it-footer {
    padding: 6px 10px;
    font-size: 0.7rem;
    color: #a16207;
    text-align: right;
    border-top: 1px dashed rgba(0, 0, 0, 0.06);
}

/* MARKDOWN STYLING INSIDE POST-IT & PREVIEW */
.markdown-content h1 { font-size: 1.1rem; margin-bottom: 4px; }
.markdown-content h2 { font-size: 1rem; margin-bottom: 4px; }
.markdown-content ul, .markdown-content ol { padding-left: 18px; margin-bottom: 6px; }
.markdown-content p { margin-bottom: 6px; }
.markdown-content code { background: rgba(0, 0, 0, 0.06); padding: 1px 4px; border-radius: 3px; font-family: monospace; }
.markdown-content pre { background: rgba(0, 0, 0, 0.08); padding: 6px; border-radius: 4px; overflow-x: auto; font-family: monospace; margin-bottom: 6px; }

/* MODAL DIALOGS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-dialog {
    background: white;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.note-modal-dialog {
    max-width: 680px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#noteForm {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.editor-container {
    width: 100%;
    max-width: 100%;
}

#noteDescriptionInput {
    width: 100%;
    max-width: 100%;
    min-height: 140px;
    max-height: 280px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    outline: none;
}

#noteDescriptionInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.markdown-preview-container {
    width: 100%;
    max-width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 12px;
    min-height: 140px;
    max-height: 280px;
    overflow-y: auto;
    background: #fafafa;
    box-sizing: border-box;
}

/* APP FOOTER */
.app-footer {
    background: var(--bg-dark);
    color: #94a3b8;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.75rem;
}
