/* Import Font */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&display=swap');

/* Base Styles */
:root {
    --header-height: 60px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 0px;
    --default-bg-color: #6365d8;
    --transition-speed: 0.3s;
    /* Sidebar Specific Colors */
    --sidebar-bg: rgba(0, 0, 0, 0.2);
    --sidebar-item-hover-bg: rgba(255, 255, 255, 0.08);
    --sidebar-item-selected-bg: rgba(255, 255, 255, 0.15);
    --sidebar-item-selected-text: #ffffff;
    --sidebar-item-text: #cccccc;
    --sidebar-border-color: rgba(255, 255, 255, 0.1);
    /* Shrinking Header */
    --sidebar-title-original-font-size: 1.3em;
    --sidebar-title-shrunk-font-size: 0em; 
    --sidebar-title-original-padding: 20px 20px 15px 20px;
    --sidebar-title-shrunk-padding: 0px 20px 0px 20px; 
    --sidebar-title-original-max-height: 60px; 
    --sidebar-title-shrunk-max-height: 0px;
}

body {
    background-color: var(--default-bg-color);
    font-family: 'Nunito Sans', sans-serif;
    color: #fff;
    margin: 0;
    padding-top: var(--header-height);
    padding-left: var(--sidebar-collapsed-width);
    font-size: 16px;
    box-sizing: border-box;
    transition: padding-left var(--transition-speed) ease;
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

body.sidebar-visible {
    padding-left: var(--sidebar-width);
}

/* Page Header Styles */
.page-header {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 0 15px 0 60px;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: var(--sidebar-collapsed-width);
    right: 0;
    z-index: 1000;
    box-sizing: border-box;
    transition: left var(--transition-speed) ease;
}
body.sidebar-visible .page-header {
    left: var(--sidebar-width);
}
.page-header h1 {
    color: #fff;
    font-weight: 700;
    font-size: 1.5em;
    margin: 0;
    white-space: nowrap;
}

/* Sidebar Toggle Button */
#sidebar-toggle {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1100;
    background-color: transparent;
    color: rgba(255, 255, 255, 0.8);
    border: none;
    width: 60px;
    height: var(--header-height);
    font-size: 1.8em;
    line-height: var(--header-height);
    text-align: center;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, color 0.2s ease;
}
#sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Left Sidebar Styles */
#category-sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    position: fixed;
    top: var(--header-height);
    left: 0;
    background-color: var(--sidebar-bg);
    box-sizing: border-box;
    z-index: 900;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
    transition: transform var(--transition-speed) ease, background-color var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}
body.sidebar-visible #category-sidebar {
    transform: translateX(0);
}

.sidebar-header-controls {
    position: sticky;
    top: 0; 
    z-index: 20; 
    background-color: var(--sidebar-bg); 
}

#category-sidebar h2 {
    font-size: var(--sidebar-title-original-font-size);
    padding: var(--sidebar-title-original-padding);
    max-height: var(--sidebar-title-original-max-height); 
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    border-bottom: 1px solid var(--sidebar-border-color);
    overflow: hidden; 
    white-space: nowrap; 
    transition: font-size var(--transition-speed) ease, 
                padding var(--transition-speed) ease,
                max-height var(--transition-speed) ease,
                opacity var(--transition-speed) ease,
                border-bottom-color var(--transition-speed) ease;
    opacity: 1;
}

#category-sidebar h2.sidebar-title-shrunk {
    font-size: var(--sidebar-title-shrunk-font-size);
    padding: var(--sidebar-title-shrunk-padding);  
    max-height: var(--sidebar-title-shrunk-max-height); 
    opacity: 0; 
    border-bottom-color: transparent; 
}

#category-sidebar .search-container {
    background-color: var(--sidebar-bg); 
    padding: 15px 20px 10px 20px;
    /* z-index: 10; /* Not strictly needed as it's part of sticky .sidebar-header-controls */
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#category-sidebar #category-search {
    width: 100%;
    padding: 12px 35px 12px 18px;
    font-size: 0.95em;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(0, 0, 0, 0.2);
    color: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
#category-sidebar #category-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}
#category-sidebar #category-search:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background-color: rgba(0, 0, 0, 0.3);
}
#category-sidebar #category-search::-webkit-search-cancel-button,
#category-sidebar #category-search::-webkit-search-clear-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.clear-search-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.5em;
    line-height: 1;
    padding: 0 5px;
    cursor: pointer;
    display: none;
}
.clear-search-button:hover {
    color: #fff;
}

#category-sidebar #category-list-container {
    padding: 10px 20px 20px 20px;
    flex-grow: 1; 
    overflow-y: auto; 
    text-align: left;
}

#category-sidebar ul.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
#category-sidebar li.category-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    color: var(--sidebar-item-text);
    font-size: 0.95em;
    border-radius: 6px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#category-sidebar li.category-item:hover {
    background-color: var(--sidebar-item-hover-bg);
    color: var(--sidebar-item-selected-text);
}
#category-sidebar li.category-item.selected {
    background-color: var(--sidebar-item-selected-bg);
    font-weight: bold;
    color: var(--sidebar-item-selected-text);
}
#category-sidebar .loading-text,
#category-sidebar .no-results-text,
#category-sidebar .error-text {
    color: rgba(255, 255, 255, 0.7);
    padding: 20px 15px;
    text-align: center;
    font-style: italic;
}

/* Main Content Area Styles */
#main-content {
    padding: 30px;
    box-sizing: border-box;
    min-height: calc(100vh - var(--header-height) - 60px);
}
.container {
    text-align: center;
    background-color: rgba(0, 0, 0, 0.1);
    padding: 30px 40px;
    border-radius: 8px;
    max-width: 650px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
}

.info-text {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9em;
    margin-top: -15px;
    margin-bottom: 25px;
}

a {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
a:hover { opacity: 0.8; }

/* Topic Box (Container for Tag and Text) */
.topic-box {
    background-color: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    color: #eee;
    border-radius: 6px;
    line-height: 1.6;
    text-align: left;
}

/* Category Tag/Pill Style */
.category-tag {
    display: none;
    padding: 5px 14px;
    font-size: 0.8em;
    font-weight: 600;
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    margin-bottom: 12px;
    line-height: 1.3;
    text-transform: capitalize;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Style for the actual topic text span */
#topic-actual-text {
    display: block;
    font-size: 1.3em;
    line-height: 1.5;
    color: #eee;
    width: 100%;
}

/* Timer Section */
.timer-section {
    margin-bottom: 30px;
}
#timer-display {
    font-size: 5em;
    font-weight: 700;
    display: block;
    margin-bottom: 15px;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}
.timer-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
}
.timer-button {
    padding: 10px 20px;
    font-size: 1em;
    color: #fff;
    background-color: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    min-width: 80px;
}
.timer-button:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
}
.timer-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Action Buttons */
.main-action-button {
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--default-bg-color);
    background-color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    display: block;
    width: 100%;
    /* margin-top: 10px; /* Will be overridden by specific button margins */
    text-transform: uppercase;
    letter-spacing: 1px;
}
#new-topic-btn { /* Specific margin for the first button */
    margin-top: 10px;
}

.main-action-button:hover:not(:disabled) {
    background-color: #f0f0f0;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}
.main-action-button:active:not(:disabled) {
     transform: translateY(2px);
     box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Secondary Action Button Style */
.secondary-action-button {
    padding: 12px 25px; /* Slightly less padding */
    font-size: 1em;    /* Slightly smaller font */
    font-weight: normal; /* Normal weight */
    color: #fff; /* Text color white */
    background-color: transparent; /* Transparent background */
    border: 2px solid rgba(255, 255, 255, 0.6); /* White border */
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    box-shadow: none; /* No shadow or very subtle */
    display: block;
    width: 100%;
    margin-top: 15px; /* Space from the button above */
    text-transform: none; /* Normal text transform */
    letter-spacing: 0.5px;
}
.secondary-action-button:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}
.secondary-action-button:active:not(:disabled) {
    transform: translateY(1px);
}


/* MOBILE OVERLAY STYLES */
@media (max-width: 768px) {
    body.sidebar-visible {
        padding-left: 0;
    }
    body.sidebar-visible .page-header {
        left: 0;
    }
    #category-sidebar {
        background-color: rgba(99,101,216, 0.92); 
        z-index: 1050; 
    }
    .sidebar-header-controls,
    #category-sidebar h2,
    #category-sidebar .search-container {
         background-color: rgba(99,101,216, 0.92); 
    }
}
