/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Page Wrapper */
.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Main Content Area */
.main-content {
    flex: 1 0 auto;
    width: 100%;
    padding: 20px 0 40px 0; /* Bottom padding untuk memberi ruang footer */
    margin-bottom: 0;
}

/* PWA Install Banner */
.pwa-install-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1050;
    display: none;
}

.banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.banner-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-install {
    background: white;
    color: #667eea;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s ease;
}

    .btn-install:hover {
        background: #f8f9fa;
        transform: translateY(-1px);
    }

.btn-dismiss {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
    transition: opacity 0.3s ease;
}

    .btn-dismiss:hover {
        opacity: 0.8;
    }

/* Calculator Container */
.calculator-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

/* App Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

    .app-header h1 {
        margin: 0;
        font-size: 1.8rem;
        font-weight: 600;
    }

        .app-header h1 i {
            margin-right: 10px;
        }

.pwa-status {
    display: flex;
    gap: 15px;
}

.status-online, .status-offline, .status-installed, .status-notinstalled {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.status-online {
    background: rgba(40, 167, 69, 0.9);
}

.status-online i {
    color: white;
}

.status-offline {
    background: rgba(220, 53, 69, 0.9);
}

.status-offline i {
    color: white;
}

.status-installed {
    background: rgba(23, 162, 184, 0.9);
    color: white;
}

.status-notinstalled {
    background: rgba(255, 193, 7, 0.9);
    color: #212529;
}

/* Card Styling */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    margin-bottom: 25px;
    background: white;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    }

.card-header {
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    border-bottom: 2px solid var(--primary-color);
    padding: 18px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .card-header h3 {
        margin: 0;
        font-size: 1.3rem;
        font-weight: 600;
        color: #343a40;
    }

        .card-header h3 i {
            margin-right: 10px;
            color: var(--primary-color);
        }

.card-body {
    padding: 25px;
}

/* Type Selection */
.type-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.type-option {
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    height: 100%;
}

    .type-option:hover {
        border-color: #adb5bd;
        background: #f8f9fa;
    }

    .type-option.active {
        border-color: var(--primary-color);
        background: rgba(0, 123, 255, 0.05);
        box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    }

    .type-option input[type="radio"] {
        display: none;
    }

.option-content {
    text-align: center;
}

    .option-content i {
        font-size: 42px;
        color: var(--primary-color);
        margin-bottom: 15px;
    }

    .option-content h4 {
        margin: 10px 0;
        font-size: 1.2rem;
        color: #343a40;
    }

    .option-content p {
        color: #6c757d;
        font-size: 0.9rem;
        margin: 0;
    }

/* Form Styling */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #495057;
}

    .form-label i {
        color: var(--primary-color);
    }

.badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.input-group {
    border-radius: 8px;
    overflow: hidden;
}

    .input-group .form-control {
        border-radius: 0 8px 8px 0;
    }

.input-group-text {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-right: none;
    color: #495057;
    font-weight: 500;
}

.form-control {
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 15px;
    transition: all 0.3s ease;
}

    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
        outline: none;
    }

    .form-control.is-invalid {
        border-color: #dc3545;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right calc(0.375em + 0.1875rem) center;
        background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    }

.text-danger {
    font-size: 0.875rem;
    margin-top: 5px;
    display: block;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #e9ecef;
}

.btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
}

    .btn-primary:hover {
        background: linear-gradient(135deg, #0056b3, #004085);
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
    }

.btn-secondary {
    background: #6c757d;
    color: white;
}

    .btn-secondary:hover {
        background: #5a6268;
        transform: translateY(-2px);
    }

.btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
}

    .btn-success:hover {
        background: linear-gradient(135deg, #218838, #1c7430);
        transform: translateY(-2px);
    }

.btn-outline-primary, .btn-outline-success {
    background: transparent;
}

.btn-lg {
    padding: 12px 30px;
    font-size: 16px;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.result-category {
    background: #f8f9fa;
    padding: 22px;
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
    height: 100%;
}

    .result-category h4 {
        color: #343a40;
        margin-bottom: 20px;
        font-size: 1.1rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .result-category h4 i {
            color: var(--primary-color);
        }

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
}

    .result-item:last-child {
        border-bottom: none;
    }

.result-label {
    font-weight: 500;
    color: #6c757d;
    flex: 1;
}

.result-value {
    font-weight: 600;
    font-size: 15px;
    text-align: right;
    min-width: 120px;
}

.highlight {
    color: var(--primary-color);
    font-size: 16px;
}

.highlight-profit {
    color: var(--success-color);
    font-size: 18px;
    font-weight: 700;
}

.text-success {
    color: #28a745 !important;
}

.text-warning {
    color: #ffc107 !important;
}

.text-danger {
    color: #dc3545 !important;
}

/* Profit Visualization */
.profit-visualization {
    background: white;
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    margin-top: 30px;
}

    .profit-visualization h5 {
        color: #343a40;
        margin-bottom: 20px;
        font-weight: 600;
    }

.profit-bars {
    margin-top: 20px;
}

.profit-bar-container {
    margin-bottom: 20px;
}

.profit-bar-label {
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    display: flex;
    justify-content: space-between;
}

.profit-bar {
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profit-bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    transition: width 0.8s ease;
    font-size: 13px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
}

    .profit-bar-segment.cogs {
        background: linear-gradient(90deg, #dc3545, #e4606d);
    }

    .profit-bar-segment.profit {
        background: linear-gradient(90deg, #28a745, #34ce57);
    }

/* History Section */
.history-section {
    margin-top: 30px;
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

    .table th {
        background: #f8f9fa;
        border-bottom: 2px solid #dee2e6;
        padding: 15px;
        font-weight: 600;
        color: #495057;
        text-align: left;
    }

    .table td {
        padding: 15px;
        border-bottom: 1px solid #e9ecef;
        vertical-align: middle;
    }

    .table tbody tr:hover {
        background-color: rgba(0, 123, 255, 0.05);
    }

.badge {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-secondary {
    background-color: #6c757d !important;
}

/* FOOTER STYLING - FIXED SOLUTION */
.footer {
    background: #343a40;
    color: white;
    padding: 25px 0;
    margin-top: auto;
    width: 100%;
    flex-shrink: 0;
}

    .footer .container {
        max-width: 1400px;
    }

    .footer p {
        margin: 0;
        color: rgba(255, 255, 255, 0.8);
    }

    .footer .small {
        font-size: 0.875rem;
    }

.footer-links {
    margin-bottom: 10px;
}

    .footer-links a {
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        transition: color 0.3s ease;
    }

        .footer-links a:hover {
            color: white;
            text-decoration: underline;
        }

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 80px;
    right: 20px;
    min-width: 300px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

    .toast-close:hover {
        opacity: 1;
    }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 992px) {
    .calculator-container {
        padding: 0 20px;
    }

    .app-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
    }

    .form-actions {
        flex-direction: column;
    }

        .form-actions .btn {
            width: 100%;
        }
}

@media (max-width: 768px) {
    .type-options {
        grid-template-columns: 1fr;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .footer .row {
        text-align: center;
    }

    .footer .text-md-end {
        text-align: center !important;
        margin-top: 15px;
    }

    .card-body {
        padding: 20px;
    }

    .banner-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .calculator-container {
        padding: 0 15px;
    }

    .app-header {
        padding: 15px;
    }

    .card-header {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .result-value {
        text-align: left;
        min-width: auto;
    }

    .footer {
        padding: 20px 0;
    }
}

/* Print Styles */
@media print {
    .pwa-install-banner,
    .form-actions,
    .header-actions,
    .footer {
        display: none !important;
    }

    .main-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
        page-break-inside: avoid;
    }

    .result-item {
        page-break-inside: avoid;
    }

    body {
        background: white !important;
    }
}

/* CSS Variables */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --border-radius: 8px;
}
