/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;

    /* Success/Error */
    --success: #10b981;
    --error: #ef4444;
}

/* Light Theme */
body[data-theme="light"] {
    --bg-primary: #f9fafb;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --bg-hover: #d1d5db;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;

    --border: #d1d5db;
    --border-hover: #9ca3af;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
}

/* Dark Theme (not too dark) */
body[data-theme="dark"] {
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-tertiary: #334155;
    --bg-hover: #475569;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border: #334155;
    --border-hover: #475569;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ==================== Screen Toggle ==================== */
.screen {
    display: none;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.screen.active {
    display: block;
    opacity: 1;
}

/* ==================== Upload Screen ==================== */
.upload-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
}

.logo-area {
    text-align: center;
}

.logo-icon {
    width: 80px;
    height: 80px;
    color: var(--primary);
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));
}

.upload-container h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

.upload-area {
    width: 100%;
    padding: 60px 40px;
    border: 3px dashed var(--border);
    border-radius: 16px;
    background: var(--bg-primary);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--text-muted);
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.upload-area:hover .upload-icon {
    color: var(--primary);
}

.upload-text {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 500;
}

.upload-subtext {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.upload-button {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.upload-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.features {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 140px;
    transition: all 0.2s ease;
}

.feature:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.feature span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==================== Presenter Layout ==================== */
.presenter-layout {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 0;
    background: var(--bg-secondary);
}

/* Header */
.presenter-header {
    background: var(--bg-primary);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h2 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.file-name {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-weight: 500;
}

.header-right {
    display: flex;
    gap: 12px;
}

.icon-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
}

body[data-theme="light"] .theme-toggle .moon-icon {
    display: none;
}

body[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

/* Main Content with Resizable Panels */
.presenter-content {
    display: grid;
    grid-template-columns: 1fr auto 380px;
    gap: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg-secondary);
}

.current-slide-panel,
.next-slide-panel,
.notes-panel,
.tools-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    overflow: hidden;
}

.current-slide-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 16px 0 16px 16px;
    border-radius: 12px;
}

.panel-header {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.slide-counter {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    background: var(--bg-secondary);
    overflow: hidden;
}

#current-slide-canvas,
#next-slide-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
}

.drawing-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Resize Handles */
.resize-handle {
    background: transparent;
    position: relative;
    cursor: ew-resize;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle::before {
    content: '';
    position: absolute;
    background: var(--border);
    transition: background 0.2s ease;
}

.resize-handle:not(.vertical)::before {
    width: 1px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
}

.resize-handle.vertical::before {
    width: 100%;
    height: 1px;
    top: 50%;
    transform: translateY(-50%);
}

.resize-handle:hover::before {
    background: var(--primary);
}

.resize-handle:not(.vertical) {
    width: 16px;
    margin: 16px 0;
}

.resize-handle.vertical {
    height: 16px;
    cursor: ns-resize;
}

/* Side Panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    overflow: hidden;
    margin: 16px 16px 16px 0;
}

.next-slide-panel {
    height: 280px;
    flex: 0 0 280px;
    border-radius: 12px;
}

.notes-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 150px;
    border-radius: 12px;
}

.tools-panel {
    flex: 0 0 auto;
    padding: 16px;
    border-radius: 12px;
}

.next-slide-panel h3,
.notes-panel h3,
.tools-panel h3 {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 12px 12px 0 0;
}

#notes-area {
    flex: 1;
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

#notes-area::placeholder {
    color: var(--text-muted);
}

/* Tool Groups */
.tool-group {
    margin-bottom: 20px;
}

.tool-group:last-child {
    margin-bottom: 0;
}

.tool-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

/* Mode Selector */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.mode-btn svg {
    width: 20px;
    height: 20px;
}

.mode-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.mode-btn.active svg {
    color: white;
}

/* Color Options */
.color-options {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.color-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--primary);
}

/* Range Input */
#line-width {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

#line-width::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

#line-width::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.tool-button {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tool-button:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.tool-button svg {
    width: 16px;
    height: 16px;
}

/* Control Bar */
.control-bar {
    background: var(--bg-primary);
    padding: 16px 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.control-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-color: transparent;
    color: white;
}

.control-btn.primary:hover {
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.control-btn svg {
    width: 20px;
    height: 20px;
}

/* ==================== Responsive ==================== */
@media (max-width: 1200px) {
    .presenter-content {
        grid-template-columns: 1fr auto 320px;
    }
}

@media (max-width: 900px) {
    .presenter-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .side-panel {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        height: auto;
    }

    .resize-handle {
        display: none;
    }

    .control-bar {
        flex-wrap: wrap;
    }

    .control-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

@media (max-width: 600px) {
    .upload-container h1 {
        font-size: 2rem;
    }

    .features {
        gap: 16px;
    }

    .side-panel {
        grid-template-columns: 1fr;
    }
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen.active {
    animation: fadeIn 0.3s ease-out;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ==================== Laser Pointer ==================== */
.laser-pointer {
    position: absolute;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.9) 0%, rgba(239, 68, 68, 0.5) 40%, rgba(239, 68, 68, 0) 100%);
    border-radius: 50%;
    pointer-events: none;
    display: none;
    transform: translate(-50%, -50%);
    z-index: 1000;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8), 0 0 20px rgba(239, 68, 68, 0.4);
}

.laser-pointer.active {
    display: block;
}

/* ==================== Utility Classes ==================== */
.cursor-pen {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M4 20h4l10.5 -10.5a1.5 1.5 0 0 0 -4 -4l-10.5 10.5v4" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="%23fff"/><path d="M13.5 6.5l4 4" stroke="%23333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>') 4 20, auto !important;
}

.cursor-laser {
    cursor: none !important;
}
