/* ==========================================================================
   Design System & Styling Rules
   ========================================================================== */

:root {
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* Color Palette (HSL Tailored) */
    --bg-app: hsl(225, 25%, 6%);
    --bg-card: hsla(224, 20%, 12%, 0.7);
    --bg-input: hsl(223, 16%, 10%);
    --bg-drawer: hsl(223, 20%, 10%);
    --bg-overlay: rgba(3, 7, 18, 0.6);
    
    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 65%);
    --text-muted: hsl(215, 14%, 45%);

    --accent-purple: hsl(263, 75%, 63%);
    --accent-purple-glow: hsla(263, 75%, 63%, 0.3);
    --accent-blue: hsl(199, 89%, 48%);
    --accent-blue-glow: hsla(199, 89%, 48%, 0.3);
    
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(147, 51, 234, 0.2);
    
    --glow-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
    background: hsl(223, 15%, 20%);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(223, 15%, 30%);
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    padding: 0 1.5rem;
}

/* Progress Bar indicator */
.timer-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: hsla(223, 15%, 15%, 0.3);
    z-index: 1000;
}

.timer-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    box-shadow: 0 0 8px var(--accent-purple-glow);
    transition: width 0.1s linear;
}

/* Header & Controls styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.logo-glow {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-purple);
    filter: blur(14px);
    opacity: 0.45;
    z-index: 1;
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-purple);
    position: relative;
    z-index: 2;
    animation: pulse-glow 3s infinite ease-in-out;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub-brand {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer-status {
    background: hsla(223, 15%, 15%, 0.4);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-glass);
}

.timer-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.65rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

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

.control-btn:hover {
    color: var(--text-primary);
    background: var(--border-glass);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

.refresh-btn-pulse:hover {
    box-shadow: 0 0 12px var(--accent-blue-glow);
    border-color: rgba(14, 165, 233, 0.4);
}

.settings-btn:hover {
    box-shadow: 0 0 12px var(--accent-purple-glow);
    border-color: rgba(168, 85, 247, 0.4);
}

/* Main Dashboard layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.5rem;
    flex-grow: 1;
    margin-bottom: 2rem;
}

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

/* Card base styling */
.media-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glow-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
    position: relative;
}

.media-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

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

.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.card-icon {
    width: 16px;
    height: 16px;
}

.text-unsplash {
    color: var(--accent-blue);
}

.text-tenor,
.text-giphy {
    color: var(--accent-purple);
}

.tag-badge {
    background: hsla(263, 75%, 63%, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: var(--accent-purple);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    text-transform: uppercase;
}

.unsplash-card #photoTagBadge {
    background: hsla(199, 89%, 48%, 0.15);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: var(--accent-blue);
}

/* Media Containers */
.media-container {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #090d16;
    overflow: hidden;
}

.unsplash-card .media-container {
    min-height: 480px;
}

.media-element {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.media-element.loaded {
    opacity: 1;
}

/* Tenor board right side layout */
.gifs-board {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gifs-board .card-header {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-glass);
}

.gifs-grid {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 1rem;
    flex-grow: 1;
}

.gif-card .media-container {
    height: 145px;
}

@media (max-width: 1024px) {
    .gifs-grid {
        grid-template-rows: unset;
        grid-template-columns: repeat(3, 1fr);
    }
    .gif-card .media-container {
        height: 180px;
    }
}

@media (max-width: 640px) {
    .gifs-grid {
        grid-template-columns: 1fr;
    }
    .gif-card .media-container {
        height: 200px;
    }
}

/* Photo Credits Overlay styling */
.credits-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1.25rem 1.25rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 20%, rgba(0, 0, 0, 0.4) 70%, transparent);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    transform: translateY(20px);
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 5;
}

.media-container:hover .credits-overlay {
    transform: translateY(0);
    opacity: 1;
}

.credits-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.by-text, .on-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.photographer-name {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.photographer-name:hover {
    color: var(--accent-blue);
    text-shadow: 0 0 6px var(--accent-blue-glow);
}

.platform-link {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-decoration: underline;
    transition: var(--transition-smooth);
}

.platform-link:hover {
    color: var(--text-primary);
}

.download-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: var(--transition-smooth);
}

.download-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.download-btn svg {
    width: 16px;
    height: 16px;
}

/* Skeleton Loading screen styling */
.skeleton-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0b0f19;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skeleton-pulse {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #0b0f19 25%,
        #151c2e 50%,
        #0b0f19 75%
    );
    background-size: 200% 100%;
    animation: skeleton-glow 1.5s infinite;
}

/* Slide-out Drawer Panel styling */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.active {
    opacity: 1;
}

.settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-drawer);
    border-left: 1px solid var(--border-glass);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-drawer.active {
    transform: translateX(0);
}

@media (max-width: 480px) {
    .settings-drawer {
        width: 100%;
    }
}

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

.drawer-header h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

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

.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-section h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-purple);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.section-icon {
    width: 16px;
    height: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input[type="text"],
.input-group input[type="password"] {
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.input-group input[type="text"]:focus,
.input-group input[type="password"]:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.15);
}

.input-helper {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Custom Slider styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-container input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-input);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-purple);
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-purple-glow);
    transition: var(--transition-smooth);
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 35px;
    text-align: right;
}

.drawer-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-glass);
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0.75rem;
}

.primary-btn, .secondary-btn {
    padding: 0.85rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.primary-btn {
    background: var(--accent-purple);
    border: none;
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--accent-purple-glow);
}

.primary-btn:hover {
    background: hsl(263, 75%, 68%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--accent-purple-glow);
}

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

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

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

/* Footer styling */
.app-footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border-glass);
    text-align: center;
}

.app-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Helpers */
.hidden {
    display: none !important;
}

.rotate {
    animation: rotate 1s linear infinite;
}

/* Animations */
@keyframes skeleton-glow {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 2px var(--accent-purple-glow));
    }
    50% {
        transform: scale(1.08);
        filter: drop-shadow(0 0 8px var(--accent-purple));
    }
}

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