/* CSS Custom Properties for Theming */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #232323;
    --bg-tertiary: #22242A;
    --text-primary: #fff;
    --text-secondary: #a0a0a0;
    --text-muted: #bebebe;
    --accent: #007bff;
    --accent-hover: #0660b2;
    --border: #2d2d2d;
    --border-hover: #404040;
    --shadow: rgba(40, 75, 125, 0.08);
    --upload-bg: #232323;
    --upload-border: #2d2d2d;
    --upload-hover: #232C3E;
}

[data-theme="light"] {
    --bg-primary: #fff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e5eef9;
    --text-primary: #232323;
    --text-secondary: #6c757d;
    --text-muted: #bebebe;
    --accent: #007bff;
    --accent-hover: #0660b2;
    --border: #dfdfdf;
    --border-hover: #bdbdbd;
    --shadow: rgba(0, 0, 0, 0.09);
    --upload-bg: #f5f7fa;
    --upload-border: #dadada;
    --upload-hover: #dde6ef;
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Layout */
.container {
    height: 100vh;
    width: 100vw;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    min-height: 0;
    height: 100vh;
    flex-direction: row-reverse; /* 👈 flips the order */
}

.left-panel {
    position: absolute;
    right: 24px;
    bottom: 24px;
    width: 340px;
    max-height: calc(100vh - 48px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Controls */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

/* Custom Dropdowns */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-item.uploaded-font { color: var(--text-primary); }

.custom-dropdown-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    outline: none;
    font-family: inherit;
}

.custom-dropdown-toggle:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

.custom-dropdown-toggle:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

.dropdown-arrow {
    margin-left: 8px;
    pointer-events: none;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu - NO SCROLLBAR */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 8px 0;
    margin: 0;
    list-style: none;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Remove scrollbar completely */
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Hide scrollbar for Chrome/Safari */
.custom-dropdown-menu::-webkit-scrollbar {
    display: none;
}

.custom-dropdown.open .custom-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-dropdown-item {
    cursor: pointer;
    padding: 12px 16px;
    color: var(--text-primary);
    border: none;
    background: none;
    font-size: 14px;
    transition: all 0.15s ease;
    font-family: inherit;
    border-radius: 4px;
    margin: 0 8px;
}

.custom-dropdown-item:hover,
.custom-dropdown-item:focus {
    background: var(--accent);
    color: var(--text-primary);
    outline: none;
}

.custom-dropdown-item.active {
    background: var(--accent);
    color: var(--text-primary);
}

/* Font Size Input */
.font-size-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.font-size-input:hover {
    border-color: var(--border-hover);
}

.font-size-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
    outline: none;
}

/* Upload Section */
.upload-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-area {
    min-height: 140px;
    border: 2px dashed var(--upload-border);
    background: var(--upload-bg);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 20px;
    gap: 12px;
}

.upload-area:hover,
.upload-area.drag-over {
    background: var(--upload-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.upload-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.upload-icon {
    width: 32px;
    height: 32px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    margin-bottom: 8px;
}

.upload-area:hover .upload-icon {
    opacity: 1;
}

.upload-text {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.upload-subtext {
    font-size: 11px;
    color: var(--text-muted);
}

/* Export Section */
.export-section {
    margin-top: auto;
    padding-top: 16px;
}

.download-btn {
    width: 100%;
    padding: 14px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: inherit;
}

.download-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.download-btn:active {
    transform: translateY(0);
}

.download-icon {
    width: 18px;
    height: 18px;
}

/* Theme Toggle */
.theme-toggle {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 100;
  width: 45px;
  height: 45px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
  transform: scale(1.05);
}

.theme-icon {
  width: 18px;
  height: 18px;
  transition: opacity 0.3s ease;
}

.sun-icon {
  opacity: 1;
  width: 19px;
  height: 19px;
}

.moon-icon {
  opacity: 0;
  position: absolute;
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
}

[data-theme="light"] .sun-icon {
    opacity: 1;
}

[data-theme="light"] .moon-icon {
    opacity: 0;
}

/* Right Panel */
.right-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg-primary);
    overflow: hidden;
}

.text-preview-container {
    width: 100%;
    height: 100%;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.text-preview {
    font-size: 52px;
    font-weight: 400;
    color: var(--text-primary);
    text-align: center;
    outline: none;
    border: none;
    background: transparent;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
    letter-spacing: -0.02em;
    min-height: 60px;
    width: 100%;
    cursor: text;
    transition: color 0.2s ease;
}

.text-preview:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.text-preview:focus {
    color: var(--text-primary);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);

    /* Animate from LEFT */
    transform: translateX(-400px);
    opacity: 0;

    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    font-weight: 500;
    max-width: 320px;
    z-index: 10000;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    border-color: #28a745;
    background: #d4edda;
    color: #155724;
}

.toast.error {
    border-color: #dc3545;
    background: #f8d7da;
    color: #721c24;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .left-panel {
        width: 300px;
        min-width: 300px;
        max-width: 300px;
    }

    .text-preview {
        font-size: 40px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .left-panel {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 320px;
        max-height: 50vh;
    }

    .theme-toggle {
        top: 16px;
        right: 16px;
    }

    .right-panel {
        padding: 20px;
        min-height: 50vh;
    }

    .text-preview {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .left-panel {
        padding: 16px;
        gap: 16px;
    }

    .control-section {
        gap: 16px;
    }

    .text-preview {
        font-size: 20px;
    }

    .upload-area {
        min-height: 100px;
        padding: 16px;
    }

    .upload-icon {
        width: 24px;
        height: 24px;
    }
}