:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --bg-color: #F3F4F6;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-color: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* Header & Navigation */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.btn {
    padding: 0.6rem 1.2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* Page Manager View */
#pages-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.page-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.page-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.page-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Frame Grid */
#frames-view {
    display: none;
}

.frames-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#current-page-title {
    font-size: 1.5rem;
    color: var(--text-color);
}

.frames-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Single Frame Component */
.frame {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255, 0.6);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.2s;
}

.frame:focus-within {
    transform: scale(1.01);
    border-color: var(--primary-color);
}

/* Note input */
.frame-note {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 40px;
    background: rgba(255,255,255, 0.9);
    transition: border-color 0.2s;
}

.frame-note:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Media Uploader */
.media-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    cursor: pointer;
    background: rgba(243, 244, 246, 0.5);
    transition: all 0.2s;
    min-height: 180px;
    position: relative;
    overflow: hidden;
}

.media-upload-area:hover, .media-upload-area.dragover {
    background: rgba(79, 70, 229, 0.05);
    border-color: var(--primary-color);
}

.media-upload-area i {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.upload-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
}

.file-input {
    display: none;
}

/* Media Preview */
.media-preview {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    background: transparent;
}

.media-preview img, .media-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.frame.has-media .media-preview {
    display: block;
}
.frame.has-media .media-upload-area {
    border: none;
}
.frame.has-media .upload-text,
.frame.has-media .fa-cloud-upload-alt {
    display: none;
}

.change-media-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
}

.media-upload-area:hover .change-media-btn {
    opacity: 1;
}

/* Tags */
.tags-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: auto;
}

.tags-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.tag-remove {
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.8;
    transition: all 0.2s;
}

.tag-remove:hover {
    opacity: 1;
    color: #ffcccc;
}

.btn-add-tag {
    background: transparent;
    border: 1px dashed var(--primary-color);
    color: var(--primary-color);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s;
}

.btn-add-tag:hover {
    background: rgba(79, 70, 229, 0.1);
}

/* Actions */
.frame-actions {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--danger-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.frame:hover .frame-actions {
    opacity: 1;
    transform: scale(1);
}

.frame-actions:hover {
    background: #B91C1C;
    transform: scale(1.1);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    display: none;
}
.frame.uploading .loading-overlay {
    display: flex;
}

.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(79, 70, 229, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .frames-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Screen Styles */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.8rem;
    font-size: 1.1rem;
}

.error-msg {
    color: var(--danger-color);
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

/* Hide main content when logged out */
body.logged-out .container {
    display: none;
}
