/* =====================================================
   CHRISTMAS TREE - PAGE-SPECIFIC STYLES
   ===================================================== */

/* ===== BODY & BACKGROUND ===== */
body {
    padding-top: 50px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    overflow: hidden;
    height: 100vh;
    color: #333;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ===== MAIN LAYOUT ===== */
.main-container {
    display: flex;
    height: calc(100vh - 50px);
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.tree-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    min-width: 0;
    overflow: hidden;
}

.tree-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 800px;
}

#treeCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    cursor: grab;
}

#treeCanvas:active {
    cursor: grabbing;
}

/* ===== SCHEDULE BUTTON ===== */
.schedule-button {
    position: fixed;
    top: 65px;
    right: 470px;
    background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(71, 118, 230, 0.4);
    transition: all 0.3s;
    z-index: 100;
}

.schedule-button span {
    display: none;
}

.schedule-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(71, 118, 230, 0.6);
}

.schedule-button::after {
    content: 'Schedule';
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.schedule-button:hover::after {
    opacity: 1;
}

/* ===== SCHEDULE MODAL ===== */
.schedule-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1000;
}

.schedule-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.schedule-container {
    background: white;
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

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

.schedule-header {
    background: linear-gradient(135deg, #4776E6 0%, #8E54E9 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.schedule-header h2 {
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-schedule {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-schedule:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
}

.close-schedule:active {
    transform: rotate(90deg) scale(0.95);
}

.schedule-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #f8f9fa;
}

.schedule-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 20px;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.time-column {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-top: 40px;
}

.time-label {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.day-column {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.day-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

.day-schedule {
    position: relative;
    height: 1440px;
    background: repeating-linear-gradient(
        to bottom,
        #fff 0px,
        #fff 59px,
        #f5f5f5 59px,
        #f5f5f5 60px
    );
}

.schedule-block {
    position: absolute;
    left: 5px;
    right: 5px;
    background: #4CAF50;
    color: white;
    border-radius: 5px;
    padding: 5px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.schedule-block:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.schedule-block.inactive {
    background: #9e9e9e;
    opacity: 0.7;
}

.add-schedule-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.quick-action-btn {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
    width: 450px;
    min-width: 350px;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.98);
    overflow-y: auto;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.panel-header h1 {
    font-size: 1.5em;
    margin-bottom: 3px;
}

.panel-header p {
    font-size: 0.9em;
    opacity: 0.9;
}

.panel-content {
    padding: 20px;
    flex-grow: 1;
}

.section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== CONNECTION STATUS ===== */
.connection-status {
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 15px;
}

.connection-status.connected {
    background: #d4edda;
    color: #155724;
}

.connection-status.disconnected {
    background: #f8d7da;
    color: #721c24;
}

.connection-status.connecting {
    background: #fff3cd;
    color: #856404;
}

/* ===== INFO & DEBUG ===== */
.info-box {
    background: #e7f3ff;
    border-left: 4px solid #2196F3;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 13px;
}

.debug-log {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-top: 10px;
}

.debug-log div {
    margin: 2px 0;
    padding: 2px;
}

.debug-log .success { color: #28a745; }
.debug-log .error { color: #dc3545; }
.debug-log .info { color: #007bff; }

/* ===== BUTTONS ===== */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

button.active {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.6);
}

button.danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

button.danger:hover {
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
}

/* ===== COLOR SELECTOR ===== */
.color-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    background-color: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border: 3px solid #ddd;
    border-radius: 8px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 5px;
}

input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 5px;
}

/* ===== BRIGHTNESS ===== */
.brightness-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
}

input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.brightness-value {
    min-width: 50px;
    text-align: right;
    font-weight: 600;
    color: #667eea;
}

/* ===== TEXT INPUTS ===== */
input[type="text"],
input[type="time"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
    transition: border 0.3s;
}

input[type="text"]:focus,
input[type="time"]:focus {
    outline: none;
    border-color: #667eea;
}

/* ===== EFFECTS GRID ===== */
.effects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.effect-btn {
    margin: 0;
    padding: 10px;
    font-size: 13px;
}

/* ===== COLOR PALETTE ===== */
.color-palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.palette-color {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
}

.palette-color:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.palette-color.selected {
    border-color: #667eea;
    transform: scale(1.1);
}

/* ===== SAVED DESIGNS ===== */
.design-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
}

.design-item button {
    width: auto;
    margin: 0 5px;
    padding: 8px 15px;
}

.delete-btn {
    background: #dc3545 !important;
    padding: 8px 12px !important;
}

/* ===== STATUS MESSAGE ===== */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== ANIMATED EFFECTS GRID ===== */
.animated-effects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.animated-effects-grid button {
    margin: 0;
    padding: 10px;
    font-size: 13px;
}

.animated-effects-grid button:last-child {
    grid-column: 1 / -1;
}

/* =====================================================
   TREE RESPONSIVE
   ===================================================== */

@media (max-width: 1200px) {
    .control-panel {
        width: 380px;
        min-width: 320px;
    }

    .schedule-button {
        right: 400px;
    }

    .panel-header h1 {
        font-size: 1.3em;
    }

    .section {
        padding: 15px;
    }

    .effects-grid {
        gap: 8px;
    }

    .effect-btn {
        padding: 8px;
        font-size: 12px;
    }
}

@media (max-width: 1024px) {
    body {
        padding-top: 50px;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .main-container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 50px);
        overflow: visible;
    }

    .tree-view {
        width: 100%;
        height: 50vh;
        min-height: 350px;
        max-height: 500px;
        order: 1;
        padding: 15px;
        flex: none;
    }

    .tree-container {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
    }

    .control-panel {
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        order: 2;
        flex: 1;
        min-height: auto;
        max-height: none;
        background: #fff;
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.2);
    }

    .schedule-button {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        z-index: 100;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 50px;
    }

    .main-container {
        flex-direction: column;
    }

    .tree-view {
        height: 45vh;
        min-height: 280px;
        max-height: 400px;
        padding: 10px;
    }

    .control-panel {
        background: #ffffff;
    }

    .panel-header {
        padding: 12px 15px;
    }

    .panel-header h1 {
        font-size: 1.2em;
    }

    .panel-header p {
        font-size: 0.75em;
    }

    .panel-content {
        padding: 15px;
    }

    .section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .section-title {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .info-box {
        font-size: 11px;
        padding: 10px;
    }

    .debug-log {
        max-height: 120px;
        font-size: 10px;
    }

    button {
        padding: 10px 15px;
        font-size: 13px;
    }

    .effects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .effect-btn {
        padding: 8px 5px;
        font-size: 11px;
    }

    .color-selector {
        flex-direction: row;
        flex-wrap: wrap;
    }

    input[type="color"] {
        width: 50px;
        height: 50px;
    }

    .brightness-control {
        flex-wrap: nowrap;
    }

    .brightness-value {
        min-width: 45px;
    }

    .schedule-button {
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 15px;
        right: 15px;
    }

    .status-message {
        top: 60px;
        right: 10px;
        left: auto;
        max-width: calc(100% - 20px);
        font-size: 13px;
        padding: 10px 15px;
    }

    #userInfo {
        display: none !important;
    }

    .schedule-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .schedule-header {
        padding: 15px;
    }

    .schedule-header h2 {
        font-size: 16px;
    }

    .schedule-body {
        padding: 10px;
    }

    .quick-actions {
        flex-direction: column;
        gap: 8px;
    }

    .quick-action-btn {
        padding: 10px;
        font-size: 12px;
    }

    .add-schedule-panel {
        padding: 12px;
    }

    .add-schedule-panel [style*="grid-template-columns: repeat(7, 1fr)"] {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }

    .add-schedule-panel [style*="grid-template-columns: 1fr 1fr auto"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .add-schedule-panel [style*="grid-template-columns: 1fr 1fr auto"] button {
        grid-column: 1 / -1;
        width: 100% !important;
    }

    .schedule-grid {
        grid-template-columns: 50px 1fr;
        gap: 8px;
        padding: 10px;
        overflow-x: auto;
    }

    .time-label {
        font-size: 9px;
        padding-right: 3px;
    }

    .days-grid {
        grid-template-columns: repeat(7, 100px);
        gap: 5px;
    }

    .day-header {
        font-size: 11px;
        padding: 8px 5px;
    }
}

@media (max-width: 600px) {
    .tree-view {
        height: 40vh;
        min-height: 250px;
        max-height: 350px;
        padding: 8px;
    }

    .panel-content {
        padding: 12px;
    }

    .section {
        padding: 10px;
        margin-bottom: 10px;
    }

    .effects-grid {
        gap: 5px;
    }

    .effect-btn {
        padding: 7px 4px;
        font-size: 10px;
    }

    .color-palette {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }

    .design-item {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .design-item > span {
        font-size: 13px;
    }

    .design-item > div {
        display: flex;
        width: 100%;
        gap: 5px;
    }

    .design-item button {
        flex: 1;
        padding: 8px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 50px;
    }

    .tree-view {
        height: 35vh;
        min-height: 200px;
        max-height: 300px;
        padding: 5px;
    }

    .panel-header {
        padding: 10px 12px;
    }

    .panel-header h1 {
        font-size: 1.1em;
    }

    .panel-header p {
        font-size: 0.7em;
    }

    .panel-content {
        padding: 10px;
    }

    .section {
        padding: 10px;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .section-title {
        font-size: 0.9em;
        margin-bottom: 8px;
    }

    .info-box {
        font-size: 10px;
        padding: 8px;
    }

    .debug-log {
        max-height: 100px;
        font-size: 9px;
        padding: 8px;
    }

    button {
        padding: 10px 12px;
        font-size: 12px;
        margin-bottom: 8px;
    }

    .effects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .effect-btn {
        padding: 6px 3px;
        font-size: 9px;
        border-radius: 6px;
    }

    input[type="color"] {
        width: 45px;
        height: 45px;
    }

    input[type="text"],
    input[type="time"] {
        padding: 10px;
        font-size: 16px;
    }

    .color-palette {
        gap: 4px;
    }

    .palette-color {
        border-width: 2px;
    }

    .schedule-button {
        width: 50px;
        height: 50px;
        font-size: 22px;
        bottom: 15px;
        right: 15px;
    }

    .schedule-button::after {
        display: none;
    }

    .status-message {
        top: auto;
        bottom: 75px;
        right: 10px;
        left: 10px;
        text-align: center;
        font-size: 12px;
        padding: 10px;
    }

    .schedule-header {
        padding: 12px 10px;
    }

    .schedule-header h2 {
        font-size: 14px;
        gap: 5px;
    }

    .close-schedule {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .quick-action-btn {
        padding: 8px;
        font-size: 11px;
    }

    .add-schedule-panel [style*="grid-template-columns: repeat(7, 1fr)"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    .schedule-grid {
        grid-template-columns: 40px 1fr;
    }

    .time-label {
        font-size: 8px;
    }

    .days-grid {
        grid-template-columns: repeat(7, 80px);
    }

    .day-header {
        font-size: 10px;
        padding: 6px 3px;
    }
}

@media (max-width: 360px) {
    .tree-view {
        height: 30vh;
        min-height: 180px;
    }

    .effect-btn {
        font-size: 8px;
        padding: 5px 2px;
    }

    .section-title {
        font-size: 0.85em;
    }

    button {
        font-size: 11px;
        padding: 8px 10px;
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    body {
        padding-top: 45px;
    }

    .main-container {
        flex-direction: row;
        height: calc(100vh - 45px);
    }

    .tree-view {
        width: 50%;
        height: 100%;
        max-height: none;
        min-height: auto;
        order: 1;
    }

    .control-panel {
        width: 50%;
        max-width: 50%;
        height: 100%;
        max-height: 100%;
        overflow-y: auto;
        order: 2;
    }

    .schedule-button {
        top: 55px;
        bottom: auto;
        right: calc(50% + 10px);
    }
}

@media (max-width: 700px) and (orientation: landscape) {
    .tree-view {
        width: 45%;
    }

    .control-panel {
        width: 55%;
        max-width: 55%;
    }

    .schedule-button {
        right: calc(55% + 10px);
    }

    .panel-content {
        padding: 10px;
    }

    .section {
        padding: 8px;
        margin-bottom: 8px;
    }

    .effects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .effect-btn {
        padding: 5px 3px;
        font-size: 9px;
    }
}
