:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 260px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    background: var(--bg-main);
}

#app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
}

header {
    grid-column: 2;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 10;
}

.sidebar {
    grid-column: 1;
    grid-row: 1 / 3;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.main-logo {
    max-width: 100%;
    height: auto;
    display: block;
}

.sidebar-section {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-label {
    padding: 0 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-item {
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.nav-item.active {
    background: #eff6ff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

main {
    grid-column: 2;
    grid-row: 2;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    background: #f1f5f9;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.code-editor {
    flex: 1;
    border: none;
    padding: 1rem;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    background: #fdfdfd;
}

.preview-container {
    flex: 1;
    background: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.iframe-wrapper {
    width: 100%;
    max-width: 900px;
    aspect-ratio: 16/9;
    background: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.slide-frame {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
}

.slide-list {
    display: flex;
    background: white;
    border-top: 1px solid var(--border);
    padding: 0.75rem;
    overflow-x: auto;
    gap: 0.75rem;
}

.slide-thumb {
    min-width: 120px;
    height: 67px;
    background: #f1f5f9;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.2s;
    position: relative;
    user-select: none;
}

.slide-del-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.slide-thumb:hover .slide-del-btn {
    opacity: 1;
}

.slide-del-btn:hover {
    transform: scale(1.1);
    background: #dc2626;
}

.slide-thumb.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.875rem;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-danger {
    background: #dc2626;
    color: white;
    text-decoration: none;
    border-color: #b91c1c;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* Dashboard */
.dashboard {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pres-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.pres-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.pres-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background: #f1f5f9;
    position: relative;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
}

.pres-thumb-content {
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform-origin: top left;
}

.pres-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pres-title {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pres-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pres-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.action-btn {
    padding: 0.4rem;
    border-radius: 4px;
    background: #f1f5f9;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Gallery Layout */
.gallery-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

.gallery-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid var(--border);
    padding-right: 1rem;
}

.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
}

.upload-zone i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.gallery-info-box {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.gallery-main {
    display: flex;
    flex-direction: column;
}

.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
}

.img-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s;
}

.img-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.img-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.img-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.img-item:hover .img-actions {
    opacity: 1;
}

.img-actions button {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 4px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-actions .del-btn {
    color: #dc2626;
}

.img-actions .copy-btn {
    color: var(--primary);
}

.img-name {
    padding: 0.4rem;
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    color: var(--text-muted);
    background: white;
    border-top: 1px solid var(--border);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
    margin-top: auto;
}

.page-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Viewer / Lightbox */
#viewer-modal {
    background: rgba(15, 23, 42, 0.9);
}

.viewer-content {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.viewer-content img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: #0f172a;
}

.viewer-actions {
    padding: 1.5rem;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.viewer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.viewer-info span {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-main);
}

.viewer-info input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #f8fafc;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-size: 0.875rem;
    z-index: 3000;
    transition: all 0.3s;
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Modal and Form Styles */
.modal-content {
    width: 95%;
    max-width: 500px;
}

#password-form .form-group {
    margin-bottom: 1.25rem;
}

#password-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

#password-form input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

#password-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.error-msg {
    background: #fce8e6;
    color: #d93025;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.success-msg {
    background: #e6f4ea;
    color: #1e8e3e;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

@media print {

    #app,
    header,
    .sidebar,
    .slide-list {
        display: none !important;
    }

    .print-slide {
        width: 100%;
        height: 100%;
        page-break-after: always;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}