/* ============================================ */
/* === RESET & GLOBAL ===                       */
/* ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #7b4a31;
    --primary-dark: #5e3825;
    --secondary: #f78f48;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --text-dark: #1a1a2e;
    --text-medium: #555;
    --text-light: #888;
    --bg-light: #f8f9fa;
    --border: #e5e7eb;
    --white: #ffffff;
    --gradient: linear-gradient(135deg, #7b4a31 0%, #f78f48 100%);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
    --shadow-color: 0 10px 30px rgba(123, 74, 49, 0.3);
}

/* ============================================ */
/* === BODY — FULL VIEWPORT, NO SCROLL ===      */
/* ============================================ */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #7b4a31 0%, #f78f48 100%);
    color: var(--text-dark);
    position: relative;
    padding: 12px;
}

/* ============================================ */
/* === BACKGROUND DECORATION (ORBS) ===         */
/* ============================================ */
.bg-decoration {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 8s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: #7b4a31;
    top: -100px;
    left: -100px;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: #f78f48;
    bottom: -80px;
    right: -80px;
    animation-delay: 2s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: #ffb87a;
    top: 50%;
    right: 10%;
    animation-delay: 4s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -30px) scale(1.1); }
    66%      { transform: translate(-20px, 20px) scale(0.95); }
}

/* ============================================ */
/* === CONTAINER UTAMA ===                      */
/* ============================================ */
.container {
    max-width: 1000px;
    height: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideUp 0.5s ease-out;
    overflow: hidden;
}

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

/* ============================================ */
/* === TOP BAR ===                              */
/* ============================================ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.top-bar-left, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    background: var(--bg-light);
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-medium);
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--bg-light);
    border-radius: 20px;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dark);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: auto;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    background: #fff;
    color: var(--danger);
    border: 1.5px solid rgba(231, 76, 60, 0.3);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-logout:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.35);
}

/* ============================================ */
/* === HEADER + STATS (compact) ===             */
/* ============================================ */
.main-header {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    font-size: 26px;
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

.main-header h1 {
    font-size: 1.15em;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.main-header p {
    color: var(--text-medium);
    font-size: 11px;
    margin-top: 2px;
}

/* ============================================ */
/* === ✅ STATS CARDS ===                        */
/* ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #fdf6f1 0%, #fceadd 100%);
    border: 1px solid rgba(123, 74, 49, 0.15);
    border-radius: 10px;
    transition: all 0.3s ease;
    min-width: 0;
    min-height: 52px;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-color);
    border-color: var(--primary);
}

.stat-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
}

.stat-card .stat-text,
.stat-card > div:not(.stat-icon):not(.refresh-btn) {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    flex: 1 !important;
}

.stat-card h4 {
    font-size: 13px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.15;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card p {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 10.5px !important;
    color: var(--text-light) !important;
    margin: 2px 0 0 0 !important;
    padding: 0 !important;
    font-weight: 500 !important;
    line-height: 1.15 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: auto !important;
    max-height: none !important;
}

/* ============================================ */
/* === ✅ TOMBOL REFRESH DEVICE ===              */
/* ============================================ */
.refresh-btn {
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.2s ease;
    opacity: 0.6;
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: 26px;
    height: 26px;
}

.refresh-btn:hover:not(:disabled) {
    opacity: 1;
    background: rgba(123, 74, 49, 0.1);
    transform: rotate(180deg);
}

.refresh-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.refresh-btn.spinning {
    animation: spin 1s linear infinite;
    opacity: 1;
}

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

#deviceCard {
    display: flex;
    align-items: center;
    cursor: default;
}

/* ============================================ */
/* === FORM CONTAINER — NO SCROLL ===           */
/* ============================================ */
.form-container {
    background: var(--bg-light);
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.form-header {
    flex-shrink: 0;
}

.form-container h2 {
    color: var(--text-dark);
    font-size: 1em;
    font-weight: 700;
}

.form-subtitle {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 2px;
}

/* ============================================ */
/* === ✅ FORM GRID — 2 KOLOM ===                */
/* ============================================ */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 0;
}

.form-col-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.form-col-left .form-group {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.form-col-left .form-group:last-child {
    flex: 1;
    min-height: 0;
}

.form-col-left .form-group:last-child textarea {
    flex: 1;
    min-height: 60px;
    max-height: none;
}

.form-col-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.form-col-right .form-group-image {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: 0;
    min-height: 0;
}

.form-col-right .upload-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
    overflow: hidden;
    max-height: 100%;
}

/* ============================================ */
/* === FORM GROUP ===                           */
/* ============================================ */
.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    color: var(--text-dark);
    font-weight: 600;
    font-size: 11.5px;
    flex-shrink: 0;
}

.label-icon {
    font-size: 13px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 7px 11px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 12.5px;
    font-family: inherit;
    background: var(--white);
    color: var(--text-dark);
    transition: all 0.25s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(123, 74, 49, 0.12);
}

.form-group textarea {
    resize: none;
    min-height: 60px;
    max-height: 120px;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-light);
    font-size: 11px;
}

.char-counter {
    text-align: right;
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
    font-weight: 500;
}

.char-counter.warn {
    color: var(--warning);
    font-weight: 700;
}

/* ============================================ */
/* === UPLOAD AREA ===                          */
/* ============================================ */
.upload-area {
    position: relative;
    border: 2px dashed #d4bfb0;
    border-radius: 10px;
    background: var(--white);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary);
    background: #fdf6f1;
}

.upload-area.dragover {
    border-color: var(--primary);
    background: #fceadd;
    transform: scale(1.01);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-medium);
    padding: 8px;
}

.upload-icon {
    font-size: 34px;
    margin-bottom: 6px;
}

.upload-placeholder p {
    font-size: 12px;
    color: var(--text-medium);
}

.upload-placeholder strong {
    color: var(--primary);
}

.upload-placeholder small {
    font-size: 10.5px;
    color: var(--text-light);
    margin: 0;
}

.upload-preview {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 4px;
    overflow: hidden;
    max-height: 100%;
}

.upload-preview img {
    max-width: 100%;
    max-height: 160px;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: var(--shadow-md);
}

.remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: 2px solid white;
    font-size: 12px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
}

.remove-image:hover {
    transform: scale(1.15);
    background: #c0392b;
}

/* ============================================ */
/* === TOMBOL SUBMIT ===                        */
/* ============================================ */
button[type="submit"] {
    width: 100%;
    padding: 10px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: var(--shadow-color);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

button[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

button[type="submit"]:hover:not(:disabled)::before {
    left: 100%;
}

button[type="submit"]:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(123, 74, 49, 0.45);
}

button[type="submit"]:active:not(:disabled) {
    transform: translateY(0);
}

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-icon {
    font-size: 14px;
}

/* ============================================ */
/* === STATUS MESSAGE — TOAST ===               */
/* ============================================ */
.status-message {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateX(120%);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.status-message.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.status-message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 5px solid #27ae60;
}

.status-message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 5px solid #e74c3c;
}

.status-message .toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.status-message .toast-close {
    margin-left: auto;
    background: transparent;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    padding: 0 4px;
    color: inherit;
}

.status-message .toast-close:hover {
    opacity: 1;
}

@media (max-width: 480px) {
    .status-message {
        top: 12px;
        right: 12px;
        left: 12px;
        min-width: auto;
        max-width: none;
        transform: translateY(-120%);
    }
    
    .status-message.show {
        transform: translateY(0);
    }
}

/* ============================================ */
/* === FOOTER ===                               */
/* ============================================ */
.main-footer {
    text-align: center;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
}

.main-footer strong {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================ */
/* === STYLE VALIDASI FORM ===                  */
/* ============================================ */
.required {
    color: var(--danger);
    font-weight: bold;
}

.error-text {
    color: var(--danger) !important;
    font-size: 11px !important;
    margin-top: 3px !important;
    display: block;
    font-weight: 600;
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-4px); }
    75%      { transform: translateX(4px); }
}

.form-group input.input-error,
.form-group textarea.input-error {
    border-color: var(--danger) !important;
    background-color: #fdf0ef;
}

.form-group input.input-error:focus,
.form-group textarea.input-error:focus {
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.15) !important;
}

.form-group input.input-success,
.form-group textarea.input-success {
    border-color: var(--success) !important;
}

.upload-area.input-error {
    border-color: var(--danger) !important;
    background-color: #fdf0ef;
}

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

@media (max-width: 700px) {
    html, body {
        height: auto;
        overflow: auto;
    }
    
    .container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        max-width: 720px;
    }
    
    .form-container {
        overflow: visible;
        flex: none;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        flex: none;
    }
    
    .form-col-right .upload-area {
        min-height: 180px;
    }
    
    .upload-preview img {
        max-height: 220px;
    }
    
    .form-group textarea {
        min-height: 70px;
    }
}

@media (max-width: 640px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 14px;
        border-radius: 18px;
        gap: 10px;
    }
    .stats-row {
        grid-template-columns: 1fr;
    }
    .stat-card {
        padding: 10px 12px;
    }
    .main-header h1 {
        font-size: 1.1em;
    }
    .header-icon {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    .container {
        padding: 12px;
        border-radius: 14px;
    }
    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .top-bar-left, .top-bar-right {
        justify-content: center;
    }
    .main-header h1 {
        font-size: 1em;
    }
    .form-container {
        padding: 12px;
    }
    .logout-text {
        display: none;
    }
    .btn-logout {
        padding: 5px 9px;
    }
    .upload-icon {
        font-size: 28px;
    }
}

@media (max-height: 650px) and (min-width: 701px) {
    .container {
        padding: 12px 16px;
        gap: 10px;
    }
    .main-header h1 {
        font-size: 1.05em;
    }
    .main-header p {
        display: none;
    }
    .form-container {
        padding: 10px 14px;
        gap: 8px;
    }
    .form-subtitle {
        display: none;
    }
    .form-grid {
        gap: 10px;
    }
    .form-col {
        gap: 6px;
    }
    .stat-card {
        min-height: 44px;
        padding: 8px 12px;
    }
    .stat-icon {
        font-size: 18px;
    }
    .upload-icon {
        font-size: 28px;
        margin-bottom: 4px;
    }
    .upload-preview img {
        max-height: 130px;
    }
    button[type="submit"] {
        padding: 9px;
    }
    .main-footer {
        padding-top: 4px;
        font-size: 10.5px;
    }
}