:root { 
    --primary: #5b9cff;
    --primary-hover: #1e5bb8;
    --primary-glow: rgba(91, 156, 255, 0.4);
    --bg-dark: #0d0d0d;
    --bg-card: #1a1a1a;
    --bg-card-hover: #222222;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --text-muted: #8c8c8c;
    --border: #333333;
    --success: #68d391;
    --error: #fc8181;
}

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

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif; 
    line-height: 1.6; 
    color: var(--text-primary); 
    background: var(--bg-dark);
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 20px; 
}

/* Header */
header { 
    background: var(--bg-card); 
    border-bottom: 1px solid var(--border); 
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo { 
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 900; 
    color: var(--text-primary); 
    text-decoration: none;
    letter-spacing: -0.5px;
    text-transform: lowercase;
}

.brand-tag { 
    font-size: clamp(0.75rem, 1.5vw, 0.9rem);
    color: var(--text-secondary); 
    margin-left: 15px; 
    border-left: 1px solid var(--border);
    padding-left: 15px;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.github-link:hover {
    color: var(--text-primary);
    border-color: var(--primary);
    background: rgba(91, 156, 255, 0.1);
}

/* Hero */
.hero { 
    text-align: center; 
    padding: 30px 20px; 
    background: radial-gradient(circle at center, #222 0%, #0d0d0d 100%);
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.hero h1 { 
    margin: 0 0 20px 0; 
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.1;
}

.hero p { 
    font-size: clamp(1.05rem, 2.3vw, 1.25rem);
    opacity: 0.85; 
    max-width: 850px; 
    margin: 0 auto 20px auto;
    color: var(--text-secondary);
}

.hero p.hero-note {
    max-width: 780px;
    font-size: 1rem;
    opacity: 0.7;
}

.btn-cta { 
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-hover);
    color: white; 
    padding: 16px 35px; 
    text-decoration: none; 
    font-weight: 700; 
    border: none;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 20px var(--primary-glow);
    cursor: pointer;
}

.btn-cta:hover { 
    background: #174a99;
    transform: translateY(-2px); 
    box-shadow: 0 8px 30px var(--primary-glow);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #3b82f6;
    color: #ffffff;
    padding: 16px 35px;
    text-decoration: none;
    font-weight: 700;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* Content Sections */
.content-section { 
    background: var(--bg-card);
    padding: 50px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

.content-section.highlight {
    border-left: 4px solid var(--primary);
    background: linear-gradient(to right, var(--bg-card), rgba(48, 119, 227, 0.05));
}

h2 { 
    color: var(--text-primary); 
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 15px;
}

h2 svg { 
    color: var(--primary); 
    flex-shrink: 0;
}

h3 {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 12px;
}

p { 
    font-size: 1.05rem; 
    color: var(--text-secondary); 
    margin-bottom: 20px; 
    line-height: 1.8; 
}

/* Controls */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.control-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
    padding: 12px 8px;
    border-radius: 0;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
}

.control-input:focus {
    outline: none;
    border-bottom-color: var(--primary);
    box-shadow: none;
}

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

/* Remove spinner arrows from number inputs */
.control-input[type="number"]::-webkit-inner-spin-button,
.control-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.control-input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper .control-input {
    flex: 1;
    padding-right: 40px;
}

.clear-input {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
    font-weight: 300;
}

.clear-input:hover {
    color: var(--error);
}

/* Results */
.results-info {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 8px 0 0 0;
}

.results-container {
    position: relative;
    margin: 25px 0;
    height: 400px;
}

.results-list {
    width: 100%;
    height: 100%;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-y: auto;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(13, 13, 13, 0.5);
    backdrop-filter: blur(2px);
    z-index: 10;
    border-radius: 6px;
    gap: 15px;
    pointer-events: none;
}

.loading-spinner.active {
    display: flex;
}

.loading-spinner p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    background: rgba(252, 129, 129, 0.1);
    border: 2px solid var(--error);
    color: var(--error);
    padding: 20px;
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
    display: none;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.page-btn {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(91, 156, 255, 0.1);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary-hover);
    border-color: var(--primary);
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.feature-card {
    background: var(--bg-dark);
    border: 2px solid var(--border);
    padding: 30px;
    border-radius: 8px;
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.feature-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.feature-card p {
    font-size: 0.95rem;
    margin: 0;
}

/* Separator */
.separator {
    height: 1px;
    background: var(--border);
    margin: 30px 0;
    border: none;
}

/* API Info Table */
.api-info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.api-info-table tr {
    height: 60px;
}

.api-label {
    padding: 12px 16px 12px 0;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    width: 140px;
    vertical-align: middle;
}

.api-value {
    padding: 12px 8px;
    vertical-align: middle;
}

.api-value code {
    font-family: 'Courier New', monospace;
    color: var(--primary);
    word-break: break-all;
    font-size: 0.85rem;
}

.api-copy {
    padding: 12px 0 12px 8px;
    width: 40px;
    text-align: right;
    vertical-align: middle;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(91, 156, 255, 0.1);
}

.copy-btn-inline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    vertical-align: middle;
}

#copyQueryBtn {
    display: none;
}

.copy-btn-inline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(91, 156, 255, 0.1);
}

.copied-message {
    color: var(--success);
    font-size: 0.85rem;
    margin-left: 8px;
    font-weight: 600;
    animation: fadeIn 0.2s;
    display: none;
}

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

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

/* Footer */
footer { 
    text-align: center; 
    padding: 40px 20px; 
    border-top: 1px solid var(--border); 
    margin-top: 30px; 
    color: var(--text-muted);
}

footer a { 
    color: var(--text-secondary); 
    text-decoration: none; 
    transition: color 0.2s; 
}

footer a:hover { 
    color: var(--primary); 
}

/* Responsive */
@media (max-width: 768px) {
    .content-section { 
        padding: 30px 20px; 
    }
    
    .brand-tag {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        margin-top: 5px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .api-info-table {
        display: block;
    }
    
    .api-info-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
    }
    
    .api-info-table td {
        display: block;
        width: 100% !important;
        padding: 8px 0 !important;
    }
    
    .api-label {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
    
    .api-copy {
        text-align: left;
        margin-top: 10px;
    }
    
    .api-copy .btn-secondary,
    .api-copy .copy-btn {
        width: 100%;
        justify-content: center;
    }
    
}

/* Tabs */
.tabs-nav {
    position: relative;
}

.tab-btn {
    position: relative;
    margin-bottom: -2px;
}

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

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary) !important;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content.active {
    display: block;
}

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

/* =============================================
   HEADER
   ============================================= */
.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left {
    display: flex;
    align-items: center;
}

/* =============================================
   SECTION HEADERS
   ============================================= */
.section-header {
    text-align: center;
    margin-bottom: 30px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* =============================================
   API INFO SECTION
   ============================================= */
.api-info-section {
    margin-bottom: 40px;
}

.api-info-table {
    min-width: 650px;
}

.language-select {
    width: 100%;
    max-width: 400px;
}

.doc-link {
    padding: 10px 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    width: 230px;
}

.query-display {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
}

.query-display code {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.query-display .copy-btn-inline {
    flex-shrink: 0;
}

.query-display .copied-message {
    flex-shrink: 0;
    display: none;
}

/* =============================================
   TABLE SCROLL WRAPPER
   ============================================= */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* =============================================
   TABS STYLING
   ============================================= */
.tabs-container {
    margin-bottom: 40px;
}

.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn-text {
    font-weight: 400;
    opacity: 0.8;
}

/* =============================================
   CONTROL SECTIONS
   ============================================= */
.controls-section {
    margin-bottom: 50px;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.controls-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls-header .btn-secondary {
    padding: 10px 20px;
    font-size: 0.9rem;
    width: 230px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.controls-note {
    margin-top: 20px;
}

.controls-note p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.controls-note svg {
    vertical-align: middle;
    margin-right: 6px;
}

/* =============================================
   RESULTS SECTION
   ============================================= */
.results-section {
    margin-bottom: 40px;
}

.results-header {
    margin-bottom: 20px;
}

.results-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =============================================
   WORDS FROM LETTERS RESULTS
   ============================================= */
.anagram-group {
    margin-bottom: 15px;
    padding-bottom: 15px;
}

.anagram-group:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.anagram-group-header {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.anagram-words {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
}

/* =============================================
   SINGLE COLUMN GRID
   ============================================= */
.controls-grid-single {
    grid-template-columns: 1fr;
}

/* =============================================
   FOOTER
   ============================================= */
.footer-links {
    margin: 15px 0;
    font-size: 0.9rem;
    line-height: 1.8;
}

.footer-links a {
    margin: 0 8px;
    white-space: nowrap;
}

.footer-note {
    margin-top: 20px;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* =============================================
   RESPONSIVE ADJUSTMENTS
   ============================================= */
@media (max-width: 768px) {
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .controls-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .controls-header .btn-secondary {
        width: 100%;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .tab-btn-text {
        display: none;
    }
    
    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
}
