/**
 * Spam Admin - Common Components (Buttons, Cards, Forms, Tables, Modals, Badges)
 */

/* =====================================================
   Utility
   ===================================================== */
.text-muted {
    color: var(--text-muted) !important;
}

.text-center {
    text-align: center !important;
}

.text-nowrap {
    white-space: nowrap !important;
}

.w-100 {
    width: 100% !important;
}

/* =====================================================
   Page Header
   ===================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 30px;
}

.page-header-left {
    flex: 1;
    min-width: 0;
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.1;
    color: #000000;
    margin-bottom: 5px;
}

.page-subtitle {
    max-width: 760px;
    font-size: 14px;
    color: var(--text-muted);
}

.page-header-right {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:hover:not(:disabled) {
    text-decoration: none;
}

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

.btn-primary {
    background: #1E293B;
    color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
    background: #334155;
    color: #FFFFFF;
}

.btn-secondary {
    background: #FFFFFF;
    color: #333333;
    border: 1px solid #E0E0E0;
}

.btn-secondary:hover:not(:disabled) {
    background: #F5F5F5;
    color: #333333;
}

.btn-success {
    background: #2E7D32;
    color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
    background: #1B5E20;
    color: #FFFFFF;
}

.btn-danger {
    background: #F44336;
    color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
    background: #D32F2F;
    color: #FFFFFF;
}

.btn-warning {
    background: #E65100;
    color: #FFFFFF;
}

.btn-warning:hover:not(:disabled) {
    background: #BF360C;
    color: #FFFFFF;
}

.btn-info {
    background: #00838F;
    color: #FFFFFF;
}

.btn-info:hover:not(:disabled) {
    background: #006064;
    color: #FFFFFF;
}

.btn-outline-primary {
    background: transparent;
    color: #1E293B;
    border: 1px solid #1E293B;
}

.btn-outline-primary:hover:not(:disabled) {
    background: #F1F5F9;
    color: #1E293B;
}

.btn-outline-secondary {
    background: transparent;
    color: #666666;
    border: 1px solid #E0E0E0;
}

.btn-outline-secondary:hover:not(:disabled) {
    background: #F5F5F5;
    color: #333333;
}

.btn-outline-success {
    background: transparent;
    color: #2E7D32;
    border: 1px solid #2E7D32;
}

.btn-outline-success:hover:not(:disabled) {
    background: #E8F5E9;
    color: #2E7D32;
}

.btn-outline-danger {
    background: transparent;
    color: #C62828;
    border: 1px solid #C62828;
}

.btn-outline-danger:hover:not(:disabled) {
    background: #FFEBEE;
    color: #C62828;
}

.btn-outline-warning {
    background: transparent;
    color: #E65100;
    border: 1px solid #E65100;
}

.btn-outline-warning:hover:not(:disabled) {
    background: #FFF3E0;
    color: #E65100;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid #E0E0E0;
    background: #FFFFFF;
    color: #666666;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
    background: #F5F5F5;
    color: #333333;
}

/* =====================================================
   Cards
   ===================================================== */
.card {
    background: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid #E0E0E0;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.card-body {
    padding: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* =====================================================
   Forms
   ===================================================== */
.form-control {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-color);
    background: #FFFFFF;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #1E293B;
}

.form-control::placeholder {
    color: #BDBDBD;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-fieldset {
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    background: #FAFAFA;
}

.form-fieldset legend {
    padding: 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-color);
}

.required {
    color: #F44336;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-hint {
    font-size: 12px;
    color: #999999;
    margin-top: 5px;
    display: block;
}

/* =====================================================
   Search Box
   ===================================================== */
.search-box {
    margin-bottom: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    border: 1px solid #E0E0E0;
    background: #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.search-group {
    display: flex;
    flex: 1;
    min-width: 160px;
    flex-direction: column;
    gap: 6px;
}

.search-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.search-actions {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background: #F1F5F9;
    color: #1E293B;
}

.badge-success {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-danger {
    background: #FFEBEE;
    color: #C62828;
}

.badge-warning {
    background: #FFF3E0;
    color: #E65100;
}

.badge-info {
    background: #F1F5F9;
    color: #1E293B;
}

.badge-purple {
    background: #F3E5F5;
    color: #7B1FA2;
}

.badge-secondary {
    background: #F5F5F5;
    color: #666666;
}

/* =====================================================
   Tab Navigation
   ===================================================== */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #E0E0E0;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
    color: var(--text-color);
}

.tab-btn.active {
    color: #1E293B;
    border-bottom-color: #1E293B;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* =====================================================
   Modal
   ===================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background: #FFFFFF;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-dialog.modal-lg {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #E0E0E0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #666666;
    cursor: pointer;
    font-size: 24px;
}

.modal-close:hover {
    color: #333333;
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #E0E0E0;
}

/* =====================================================
   DataTables Override
   ===================================================== */
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0;
}

table.dataTable thead th {
    padding: 10px 16px;
    border-bottom: 1px solid #E0E0E0;
    font-size: 12px;
    font-weight: 600;
    color: #666666;
    text-transform: uppercase;
    background: #F5F5F5;
}

table.dataTable tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid #F0F0F0;
    font-size: 13px;
    color: var(--text-color);
    vertical-align: middle;
    background: transparent;
}

table.dataTable tbody tr {
    transition: background 0.15s ease;
}

table.dataTable tbody tr:hover {
    background: #FAFAFA;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    font-size: 13px;
    color: var(--text-muted);
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    padding: 5px 10px;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding-top: 14px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    margin: 0 2px;
    padding: 5px 10px;
    border-radius: 4px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #1E293B !important;
    color: #FFFFFF !important;
    border: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #F1F5F9 !important;
    color: #1E293B !important;
    border: none !important;
}

/* =====================================================
   Spin Animation
   ===================================================== */
.spin {
    animation: spin 1s linear infinite;
}

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

/* =====================================================
   Toggle Switch
   ===================================================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    border-radius: 22px;
    background: #CCCCCC;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    bottom: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #2E7D32;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1024px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 20px;
    }

    .page-header-right {
        width: 100%;
    }

    .page-title {
        font-size: 20px;
    }

    .page-subtitle {
        font-size: 12px;
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-group,
    .search-actions {
        width: 100%;
    }

    .search-actions {
        flex-wrap: wrap;
    }

    .tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        white-space: nowrap;
    }

    table.dataTable thead th,
    table.dataTable tbody td {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-body {
        padding: 12px;
    }

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

@media (max-width: 640px) {
    .page-title {
        font-size: 18px;
    }

    .card,
    .search-box {
        border-radius: 6px;
    }

    .card-header,
    .card-body,
    .search-box,
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 12px;
        padding-right: 12px;
    }

    .modal-dialog,
    .modal-dialog.modal-lg {
        max-width: calc(100vw - 20px);
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 80px;
    }
}
