/* PicoClock Manager - Modern Dark Theme */

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-elevated: #1a1a24;
    --bg-hover: #22222e;
    --border: #2a2a3a;
    --text-primary: #e8e8f0;
    --text-secondary: #8888a0;
    --text-muted: #5555668;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --font-sans: 'Space Grotesk', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Main Layout */
main {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    overflow-y: auto;
}

.sidebar h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-item {
    padding: 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.device-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.device-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.device-item .name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.device-item .status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.syncing {
    background: var(--warning);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Content Area */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Sync Overlay */
.sync-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--radius);
}

.sync-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.sync-message {
    font-size: 1rem;
    color: var(--text-primary);
    text-align: center;
    max-width: 300px;
}

/* Device Panel */
.device-panel {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    min-height: 400px;
}

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

.panel-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.upload-zone p {
    color: var(--text-secondary);
}

.upload-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

/* File Grid */
.time-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.time-grid-header h3 {
    font-size: 1rem;
    color: var(--text-secondary);
}

.view-toggle {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.view-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.view-btn.active {
    background: var(--accent);
    color: white;
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.25rem;
}

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
}

.file-preview {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-dark);
    background-image: 
        linear-gradient(45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a24 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a24 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.file-preview img {
    width: 96px;
    height: 96px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    transition: transform 0.2s ease;
}

.file-card:hover .file-preview img {
    transform: scale(1.15);
}

.file-info {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.file-time {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
}

.file-period {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow);
    animation: slideUp 0.3s ease;
}

.modal-small {
    max-width: 400px;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}

.modal-footer .spacer {
    flex: 1;
}

/* Preview Container */
.preview-container {
    background: var(--bg-dark);
    background-image: 
        linear-gradient(45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a24 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a24 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a24 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: var(--radius-sm);
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    min-height: 180px;
}

.preview-container img {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 2px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Time Picker */
.time-picker {
    display: flex;
    gap: 2rem;
}

.time-input-group label,
.period-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.time-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.time-inputs select {
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    cursor: pointer;
}

.time-inputs select:focus {
    outline: none;
    border-color: var(--accent);
}

.time-inputs span {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.period-buttons {
    display: flex;
    gap: 0.5rem;
}

.period-btn {
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-btn:hover {
    border-color: var(--text-secondary);
}

.period-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .device-list {
        flex-direction: row;
        overflow-x: auto;
    }
    
    .device-item {
        min-width: 150px;
    }
    
    .time-picker {
        flex-direction: column;
        gap: 1rem;
    }
}

