:root {
    --bg-color: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --danger-color: #ef4444;
}

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

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs for Aesthetic */
.background-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
}
.blob-1 {
    width: 400px;
    height: 400px;
    background: #3b82f6;
    top: -100px;
    left: -100px;
}
.blob-2 {
    width: 500px;
    height: 500px;
    background: #8b5cf6;
    bottom: -150px;
    right: -100px;
}

/* Typography & Utils */
h1, h2, h3 { font-weight: 600; }
.text-muted { color: var(--text-secondary); font-size: 0.9rem; }
.hidden { display: none !important; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
    font-family: inherit;
}
.btn-primary {
    background: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}
.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
}
.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Header */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 5%;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-auth {
    display: flex;
    align-items: center;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}
.logo i { color: var(--primary-color); }

/* Main Container */
.container {
    padding: 30px 5%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Sections */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}
.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Folder Grid */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.folder-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--glass-shadow);
    position: relative;
}
.folder-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.3);
}
.folder-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}
.btn-action {
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn-action:hover {
    background: var(--primary-color);
}
.btn-action.delete:hover {
    background: var(--danger-color);
}
.folder-icon {
    width: 50px;
    height: 50px;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}
.folder-info h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    /* Anti-download rules */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* 
  ANTI-DOWNLOAD TRICK: 
  The actual image is behind a transparent overlay. 
  Right-clicking saves the transparent overlay instead.
*/
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    pointer-events: none; /* Prevents dragging and context menu on the img itself */
}
.gallery-item:hover img {
    transform: scale(1.05);
}

/* Text Item */
.gallery-item.type-text {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--glass-border);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow-y: auto;
    word-break: break-word;
    cursor: default; /* Text is not clickable like image */
}
.gallery-item.type-text p {
    white-space: pre-wrap; /* Preserve line breaks */
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
}

/* YouTube Item */
.gallery-item.type-youtube {
    background: #000;
    cursor: default;
}
.gallery-item.type-youtube iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: auto; /* Allow interaction with iframe */
}

.image-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}
.anti-download-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    background: transparent;
    /* Extra measure to prevent selecting/highlighting */
    user-select: none;
    -webkit-user-select: none;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Inputs & Forms */
.hidden-input { display: none; }
.form-group {
    margin-bottom: 20px;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.form-group input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
    border-color: var(--primary-color);
}
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.btn-toggle-password {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
}
.error-msg {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}
.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}
.btn-close:hover { color: white; }
.modal-body {
    padding: 25px;
}
.modal-body p { margin-bottom: 20px; }
.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Lightbox for Image Preview */
.lightbox-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    pointer-events: none; /* Crucial for anti-download */
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 2rem;
    color: white;
    z-index: 201;
}

/* Upload Progress */
.upload-progress-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Skeleton Loading */
.skeleton {
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}
