/* ==============================================
   RAZ Creative Studio - Kalkulator HPP Premium
   Stylesheet: RAZHppCalc.css
   ============================================== */

/* CSS Variables: Dark & Light Mode Support */
:root[data-theme="dark"] {
    --bg-primary: #0F0F0F;
    --bg-secondary: rgba(255, 255, 255, 0.03);
    --bg-card: rgba(20, 20, 20, 0.6);
    --bg-table: rgba(0, 0, 0, 0.4);
    --text-primary: #FFFFFF;
    --text-secondary: #AAAAAA;
    --text-muted: #666666;
    --gold: #D4AF37;
    --gold-dim: rgba(212, 175, 55, 0.15);
    --border-color: rgba(212, 175, 55, 0.2);
    --border-table: rgba(255, 255, 255, 0.1);
    --danger: #FF4D4D;
    --danger-dim: rgba(255, 77, 77, 0.1);
    --success: #4CAF50;
    --glass-blur: blur(16px);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"] {
    --bg-primary: #F8F5F0;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-table: #FFFFFF;
    --text-primary: #222222;
    --text-secondary: #555555;
    --text-muted: #888888;
    --gold: #B38600;
    --gold-dim: rgba(212, 175, 55, 0.15);
    --border-color: rgba(212, 175, 55, 0.3);
    --border-table: rgba(0, 0, 0, 0.1);
    --danger: #E63946;
    --danger-dim: rgba(230, 57, 70, 0.1);
    --success: #2A9D8F;
    --glass-blur: blur(12px);
    --card-shadow: 0 8px 32px rgba(212, 175, 55, 0.15);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background Particles (Minimalist) */
.bg-particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
    opacity: 0.1;
    z-index: -1;
    pointer-events: none;
}
.bg-particle:nth-child(1) { top: 10%; left: 10%; width: 300px; height: 300px; }
.bg-particle:nth-child(2) { top: 40%; right: 5%; width: 400px; height: 400px; }
.bg-particle:nth-child(3) { bottom: -10%; left: 20%; width: 500px; height: 500px; }

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--gold);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 100;
    backdrop-filter: var(--glass-blur);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--gold-dim);
}

/* Wrapper Layout */
.calc-wrapper {
    width: 100%;
    max-width: 1400px;
    padding: 120px 20px 60px; /* 120px top to clear fixed header */
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    align-items: start;
    margin: 0 auto;
}

/* Hero Section */
.calc-hero {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 30px;
}

.calc-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.gold-text {
    color: var(--gold);
}

.calc-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 700px;
    margin: 0 auto;
}

/* Main Content Area */
.calc-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Cards (Glassmorphism) */
.calc-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
}

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

.card-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.gold-icon {
    color: var(--gold);
}

.card-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Table Design */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-table);
}

.calc-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 750px;
    background: var(--bg-table);
}

.calc-table th {
    text-align: left;
    padding: 14px 12px;
    background: var(--gold-dim);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.calc-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-table);
    vertical-align: middle;
}

.calc-table tr:last-child td {
    border-bottom: none;
}

/* Form Inputs */
.calc-input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-table);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
}

.calc-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}

/* Select specifically */
select.calc-input {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23AAAAAA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

/* Rupiah Prefix Wrapper */
.input-rp-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-table);
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease;
}
.input-rp-wrapper:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}
.rp-prefix {
    padding: 10px 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    font-size: 0.95rem;
    border-right: 1px solid var(--border-table);
}
.input-rp-wrapper .calc-input {
    border: none;
    border-radius: 0;
}
.input-rp-wrapper .calc-input:focus {
    box-shadow: none;
}

/* Dynamic Value display in table */
.val-display {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--danger);
    color: #FFF;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px dashed var(--gold);
    color: var(--gold);
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.btn-add:hover {
    background: var(--gold-dim);
}

/* Margin Input Group */
.margin-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-table);
}
.margin-input-group label {
    font-weight: 600;
    font-size: 1.1rem;
}
.input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    width: 150px;
}
.input-wrapper input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-table);
    color: var(--text-primary);
    padding: 12px 40px 12px 15px;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    outline: none;
}
.input-wrapper input:focus {
    border-color: var(--gold);
}
.input-suffix {
    position: absolute;
    right: 15px;
    color: var(--text-secondary);
    font-weight: 700;
}

/* Sticky Dashboard Panel */
.calc-dashboard {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    position: sticky;
    top: 30px;
    box-shadow: var(--card-shadow);
}

.dashboard-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.summary-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.summary-value {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}

.highlight-item {
    padding-top: 15px;
    border-top: 1px dashed var(--border-table);
    margin-top: 5px;
}
.highlight-item .summary-label {
    color: var(--text-primary);
    font-weight: 600;
}
.highlight-item .summary-value {
    font-size: 1.4rem;
}

.success-text {
    color: var(--success);
}

/* Helper Text */
.helper-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

/* Selling Price Box & Actual Performance Box */
.selling-price-box, .actual-performance-box {
    background: var(--gold-dim);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 15px;
}

.actual-performance-box {
    background: rgba(42, 157, 143, 0.05); /* Slight teal tint for contrast */
    border: 1px solid rgba(42, 157, 143, 0.3);
    text-align: left;
}
.actual-performance-box .selling-label {
    text-align: center;
    color: #2A9D8F;
}

.selling-label {
    display: block;
    color: var(--gold);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.selling-value-wrapper {
    font-family: 'Poppins', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.selling-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Dashboard Actions */
.dashboard-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: var(--gold);
    color: #FFF;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    background: #B38600;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-table);
}

.btn-secondary:hover {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: var(--danger);
}

/* Footer */
.calc-footer {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .calc-wrapper {
        grid-template-columns: 1fr;
        padding: 100px 15px 40px; /* clear fixed header on tablet */
    }
    .calc-dashboard {
        position: relative;
        top: 0;
    }
}

@media (max-width: 768px) {
    .calc-wrapper {
        padding: 90px 10px 40px; /* clear fixed header on mobile */
    }
    .calc-title {
        font-size: 2.2rem;
    }
    .calc-subtitle {
        font-size: 0.95rem;
    }
    .margin-input-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .calc-card {
        padding: 15px;
    }
    /* Mengizinkan form scroll halus tanpa merusak layout luar */
    .table-container {
        border-radius: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .input-rp-wrapper .calc-input, .calc-input {
        font-size: 16px; /* mencegah zoom otomatis di iOS Safari */
    }
}

@media (max-width: 480px) {
    .calc-title {
        font-size: 1.8rem;
    }
    .summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    .selling-value-wrapper {
        font-size: 1.8rem;
    }
}

/* Mode Toggle Switch */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-table);
}
.mode-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.toggle-switch input {
    display: none;
}
.toggle-slider {
    width: 44px;
    height: 24px;
    background-color: var(--gold-dim);
    border-radius: 24px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--gold);
    transition: 0.3s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--gold);
    top: 2px;
    left: 2px;
    transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background-color: var(--gold);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background-color: #fff;
}
.mode-text-detail, .mode-text-simple {
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 10px;
    transition: color 0.3s;
}
.mode-text-simple {
    display: none;
    color: var(--gold);
}
.toggle-switch input:checked ~ .mode-text-detail {
    display: none;
}
.toggle-switch input:checked ~ .mode-text-simple {
    display: inline;
}

/* Simple/Detail Column Display Logic */
#section-bahan[data-mode="detail"] .simple-only {
    display: none !important;
}
#section-bahan[data-mode="simple"] .detail-only {
    display: none !important;
}

/* PDF Template Base */
.pdf-template {
    width: 800px;
    background: #ffffff;
    padding: 40px;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    color: #333333;
}
