/* CSS Variables for theming */
:root {
    --tile-blue: #4285f4;
    --tile-red: #ea4335;
    --tile-yellow: #fbbc04;
    --tile-green: #34a853;
    --bg-dark: #202124;
    --text-white: #ffffff;
    --modal-bg: #2d2d30;
    --input-bg: #3c3c3c;
    --border-color: #4a4a4a;
    --primary-btn: #4285f4;
    --secondary-btn: #5f6368;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', 'Product Sans', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Dashboard container */
.dashboard-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* Settings button */
.settings-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(90deg);
}

/* Grid container */
.grid-container {
    display: grid;
    width: 100vw;
    height: 100vh;
    gap: 0;
}

/* Individual tile */
.tile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.5s ease;
}

.tile-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
    max-width: 90%;
    gap: 10px;
}

.tile-source-name {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    font-weight: 500;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tile-value {
    font-size: clamp(1.5rem, 3vw, 3rem);
    font-weight: 400;
    line-height: 1.3;
}

/* Tile colors */
.tile-blue { background-color: var(--tile-blue); }
.tile-red { background-color: var(--tile-red); }
.tile-yellow { background-color: var(--tile-yellow); }
.tile-green { background-color: var(--tile-green); }

/* Typing cursor */
.typing-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background-color: var(--text-white);
    margin-left: 2px;
    animation: blink 0.7s infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Slide animations */
@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-100%); opacity: 0; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes slideOutUp {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-100%); opacity: 0; }
}

@keyframes slideOutDown {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.slide-out-left { animation: slideOutLeft 0.5s ease forwards; }
.slide-out-right { animation: slideOutRight 0.5s ease forwards; }
.slide-out-up { animation: slideOutUp 0.5s ease forwards; }
.slide-out-down { animation: slideOutDown 0.5s ease forwards; }
.slide-in-left { animation: slideInLeft 0.5s ease forwards; }
.slide-in-right { animation: slideInRight 0.5s ease forwards; }
.slide-in-up { animation: slideInUp 0.5s ease forwards; }
.slide-in-down { animation: slideInDown 0.5s ease forwards; }

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--modal-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

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

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

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Settings sections */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 15px;
    color: #8ab4f8;
}

.setting-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 15px;
}

.setting-row label {
    min-width: 180px;
    font-size: 0.9rem;
    color: #bdc1c6;
}

.setting-row input,
.setting-row select {
    flex: 1;
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-white);
    font-size: 0.9rem;
}

.setting-row input:focus,
.setting-row select:focus {
    outline: none;
    border-color: var(--primary-btn);
}

.setting-row input[type="number"] {
    width: 100px;
    flex: none;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #5a9cf8;
}

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

.btn-secondary:hover {
    background: #71767b;
}

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

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

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Data sources list */
.data-sources-list {
    margin-bottom: 15px;
}

.data-source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--input-bg);
    border-radius: 6px;
    margin-bottom: 8px;
}

.data-source-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.data-source-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.data-source-name {
    font-weight: 500;
}

.data-source-type {
    font-size: 0.8rem;
    color: #9aa0a6;
}

.data-source-actions {
    display: flex;
    gap: 8px;
}

.data-source-actions button {
    background: none;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
    transition: color 0.2s;
}

.data-source-actions button:hover {
    color: var(--text-white);
}

.data-source-actions button.delete:hover {
    color: var(--tile-red);
}

/* Tile configuration grid */
.tile-config-grid {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.tile-config-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--input-bg);
    border-radius: 6px;
}

.tile-config-item .tile-preview {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.8rem;
}

.tile-config-item select {
    flex: 1;
    padding: 8px 10px;
    background: var(--modal-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-white);
    font-size: 0.85rem;
}

/* Hint text */
.hint {
    font-size: 0.85rem;
    color: #9aa0a6;
    margin-bottom: 10px;
}

/* API config visibility */
.api-config {
    display: none;
}

.api-config.visible {
    display: flex;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .setting-row label {
        min-width: auto;
        margin-bottom: 5px;
    }
    
    .setting-row input,
    .setting-row select {
        width: 100%;
    }
    
    .setting-row input[type="number"] {
        width: 100%;
    }
    
    .tile-content {
        font-size: clamp(1rem, 4vw, 2rem);
    }
    
    .modal {
        width: 95%;
        max-height: 90vh;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--modal-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Toggle Switch Styles */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-btn);
    transition: 0.4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--tile-green);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Chart Overlay Styles */
.chart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.chart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.chart-container {
    width: 90%;
    max-width: 1200px;
    height: 85%;
    max-height: 750px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transform: scale(0.8) translateY(50px);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.chart-overlay.active .chart-container {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.chart-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.chart-header h2 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-20px);
    animation: none;
}

.chart-overlay.active .chart-header h2 {
    animation: titleSlideIn 0.8s ease forwards 0.3s;
}

@keyframes titleSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-source {
    display: inline-block;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 3px;
    padding: 8px 20px;
    background: rgba(66, 133, 244, 0.3);
    border-radius: 20px;
    border: 1px solid rgba(66, 133, 244, 0.5);
    opacity: 0;
    transform: scale(0.8);
    animation: none;
}

.chart-overlay.active .chart-source {
    animation: badgePop 0.5s ease forwards 0.5s;
}

@keyframes badgePop {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chart-subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 15px;
    opacity: 0;
    animation: none;
}

.chart-overlay.active .chart-subtitle {
    animation: fadeIn 0.6s ease forwards 0.7s;
}

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

.chart-wrapper {
    height: calc(100% - 140px);
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    animation: none;
}

.chart-overlay.active .chart-wrapper {
    animation: chartSlideUp 0.8s ease forwards 0.4s;
}

@keyframes chartSlideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Chart Value Highlight */
.chart-highlight {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    opacity: 0;
    animation: none;
}

.chart-overlay.active .chart-highlight {
    animation: fadeIn 0.6s ease forwards 0.9s;
}

.highlight-item {
    text-align: center;
}

.highlight-value {
    font-size: 2rem;
    font-weight: 700;
    color: #4285f4;
    text-shadow: 0 0 20px rgba(66, 133, 244, 0.5);
}

.highlight-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
}

/* Glowing border animation */
.chart-overlay.active .chart-container {
    animation: glowPulse 3s ease-in-out infinite 1s;
}

@keyframes glowPulse {
    0%, 100% { 
        box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                    0 0 60px rgba(66, 133, 244, 0.1);
    }
    50% { 
        box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6),
                    0 0 80px rgba(66, 133, 244, 0.3);
    }
}

/* Data point animations for bars */
@keyframes barGrow {
    from {
        transform: scaleY(0);
    }
    to {
        transform: scaleY(1);
    }
}

/* Icon next to source badge */
.chart-source i {
    margin-right: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-container {
        padding: 20px;
        height: 90%;
    }
    
    .chart-header h2 {
        font-size: 1.5rem;
    }
    
    .chart-source {
        font-size: 0.8rem;
        padding: 6px 14px;
    }
    
    .chart-wrapper {
        height: calc(100% - 100px);
    }
    
    .chart-highlight {
        gap: 20px;
    }
    
    .highlight-value {
        font-size: 1.5rem;
    }
}
