/* ThingSpeak Dashboard Custom Styles */

/* Blue water theme colors */
:root {
    --primary-color: #1a73e8;
    --primary-dark: #0d47a1;
    --primary-light: #bbdefb;
    --accent-color: #03a9f4;
    --text-primary: #212121;
    --text-secondary: #757575;
    --bg-light: #f5f7fa;
}

/* Body styles */
body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar styling */
.navbar {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
}

.navbar-brand {
    font-weight: 700;
}

/* Card styling */
.card {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1);
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
    border-radius: 0.5rem 0.5rem 0 0 !important;
}

/* Button styling */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover, .btn-outline-primary:focus {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Back Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.35);
    transition: box-shadow 0.2s, transform 0.2s;
    text-decoration: none;
}

.btn-back:hover, .btn-back:focus {
    color: #fff;
    box-shadow: 0 4px 14px rgba(26, 115, 232, 0.5);
    transform: translateY(-1px);
}

.btn-back:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
}

/* Button Widget Styles */
.thingspeak-button {
    min-width: 150px;
    min-height: 60px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
    padding: 12px 24px;
}

.thingspeak-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.thingspeak-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.thingspeak-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Multi Button Widget Styles */
.multi-button-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.multi-button-item {
    flex: 1 1 calc(50% - 1rem);
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.thingspeak-multi-button {
    min-width: 130px;
    min-height: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
    padding: 10px 20px;
    width: 100%;
}

.thingspeak-multi-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.thingspeak-multi-button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.thingspeak-multi-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Button Widget with Indicator Styles */
.button-with-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

/* Button LED indicator styling */
.button-led-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #ccc;
    display: inline-block;
    transition: background-color 0.3s, box-shadow 0.3s;
    margin-bottom: 10px;
}

/* Active state for button LED indicators */
.button-led-indicator.active {
    background-color: #00c853;
    box-shadow: 0 0 10px #00c853;
}

/* Make sure button container positions correctly */
.button-with-indicator {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.button-led-indicator {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto;
    background-color: #ccc;
    transition: all 0.3s ease;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

/* Footer styling */
.footer {
    margin-top: auto;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
}

/* Form controls */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.25rem rgba(26, 115, 232, 0.25);
}

/* Dashboard panel styling */
.dashboard-card {
    transition: all 0.3s ease;
}

.dashboard-card .current-value {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
}

/* Table styling */
.table {
    vertical-align: middle;
}

.table tr {
    transition: background-color 0.2s;
}

/* Badge styling */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Alert styling */
.alert {
    border: none;
    border-radius: 0.5rem;
}

/* Main content container */
.main-container {
    min-height: calc(100vh - 160px);
    flex-shrink: 0;
}

/* Loading animation */
@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    50% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.7;
    }
}

.loading-spinner {
    animation: pulse 1.5s infinite ease-in-out;
    width: 50px;
    height: 50px;
    border: 4px solid var(--primary-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
}

/* Widget Card Styles */
.widget-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: auto;  /* Changed from 100% to auto */
    padding: 0;    /* Changed from 1rem to 0 */
    width: 100%;
    border-radius: 0.5rem;
    background-color: #fff;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.widget-card .card-body {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    max-height: 420px; /* Increased to fit LED widgets with units/conversion */
    overflow: hidden;
}

/* Chart and Bar Graph widgets need more height */
.col-lg-12 .widget-card .card-body {
    max-height: 350px; /* Larger for full-width chart widgets */
    min-height: 280px;
}

/* Chart Widget Styling - Adaptive Landscape */
.chart-container {
    position: relative;
    width: 100%;
    height: 280px; /* Fixed height for better chart rendering */
    margin: 0.5rem 0;
}

/* Full-width charts get more height */
.col-lg-12 .chart-container {
    height: 320px;
}

.widget-chart {
    width: 100%;
    height: 100%;
    min-height: 200px;
    position: relative;
    margin: 0;
}

.widget-bar-graph {
    width: 100%;
    height: 100%;
    min-height: 200px;
    position: relative;
    margin: 0;
}

/* Remove any point-related styling */
.widget-chart circle.point {
    display: none !important;
}

/* Chart axis labels */
.widget-chart text {
    font-size: 0.85rem !important;
}

.widget-chart .x-axis text {
    transform: rotate(-45deg);
    text-anchor: end;
}

.widget-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #01305f;
}

/* Loading state enhancement */
.loading-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* LED Widget Styles */
.led-indicator {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin: 0 auto;
    background-color: #ccc;
    transition: all 0.3s ease;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
}

.led-indicator.on {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* Widget Grid Layout - Adaptive */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
    padding: 0 1rem;
}

/* Widget List Layout */
.dashboard-list .col {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}

.dashboard-list .widget-card {
    margin-bottom: 1rem;
}

.dashboard-list .widget-chart {
    max-height: 300px;
}

/* Widget Error State */
.widget-error {
    color: #e74c3c;
    text-align: center;
    padding: 2rem;
}

/* Numeric Widget Styles */
.widget-card .card-body {
    min-height: 200px;
}

.widget-value {
    font-size: 2.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.widget-update-time {
    font-size: 0.85rem;
    color: #6c757d;
}

/* Chart Widget specific styling */
.widget-chart {
    width: 100%; 
    height: 100%;
}

/* Multi-Button Configuration Table */
.multi-button-config-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
}

.multi-button-config-table tr:not(:last-child) td {
    border-bottom: 1px solid #dee2e6;
}

.multi-button-config-table td {
    background: #fff;
    padding: 12px 8px;
}

.multi-button-config-table thead th {
    background-color: var(--primary-light);
    font-weight: 600;
    white-space: nowrap;
    padding: 12px 8px;
}

.multi-button-config-table td:first-child {
    font-weight: 600;
    color: var(--primary-dark);
    white-space: nowrap;
    width: 90px;
}

/* Column widths */
.multi-button-config-table td:nth-child(1) { width: 100px; }
.multi-button-config-table td:nth-child(2) { width: 240px; }
.multi-button-config-table td:nth-child(3) { width: 120px; }
.multi-button-config-table td:nth-child(4) { width: 240px; }
.multi-button-config-table td:nth-child(5) { width: 140px; }
.multi-button-config-table td:nth-child(6) { width: 160px; }

/* Table container */
.table-responsive {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #fff;
}

/* Input fields */
.multi-button-config-table input.form-control-sm {
    display: block;
    width: 100%;
    height: 38px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.multi-button-config-table input.form-control-sm:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(26, 115, 232, 0.25);
}

/* Container styling */
#multi-buttons-container,
#edit-multi-buttons-container {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
}

.multi-button-help {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* OAuth Divider Styling */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #dee2e6;
}

.divider:not(:empty)::before {
    margin-right: 0.75rem;
}

.divider:not(:empty)::after {
    margin-left: 0.75rem;
}

.divider-text {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Modern Google Sign-in Button */
.btn-google {
    background-color: #ffffff;
    border: 1px solid #dadce0;
    color: #3c4043;
    font-weight: 500;
    font-size: 14px;
    padding: 10px 24px;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-google:hover {
    background-color: #f8f9fa;
    border-color: #d2e3fc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    color: #3c4043;
}

.btn-google:focus {
    background-color: #f8f9fa;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.2);
    color: #3c4043;
    outline: none;
}

.btn-google:active {
    background-color: #f1f3f4;
    border-color: #5195ee;
    color: #3c4043;
}
