/**
 * Dynamic Redirect Manager - v1.7.0
 * Adds styles for Shuffle, IST Timestamps, and fixes table layouts.
 */

/* --- 0. Global & Resets --- */
#drm-shortcode-wrap *,
#drm-admin-wrap * {
    box-sizing: border-box;
}

.drm-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.drm-no-slugs {
    padding: 20px 0;
}

/* --- 1. Buttons --- */
#drm-shortcode-wrap .button,
#drm-admin-wrap .button,
.drm-form .button {
    padding: 5px 12px;
    font-size: 0.9em;
    height: auto;
    line-height: 1.6;
    margin: 0;
    cursor: pointer;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.1s ease-in-out;
    background: #fff;
    border: 1px solid #e10078;
    color: #e10078;
    box-shadow: none;
    text-shadow: none;
}
#drm-shortcode-wrap .button:hover,
#drm-admin-wrap .button:hover,
.drm-form .button:hover {
    background: #e10078;
    color: #fff;
}
#drm-toggle-add-slug-form {
    margin-bottom: 20px;
    font-weight: bold;
}
#drm-shortcode-wrap .button.button-primary,
#drm-admin-wrap .button.button-primary,
.drm-form .button.button-primary {
    background: #e10078;
    color: #fff;
    border-color: #e10078;
}
#drm-shortcode-wrap .button.button-primary:hover,
#drm-admin-wrap .button.button-primary:hover,
.drm-form .button.button-primary:hover {
    background: #c4006a;
    border-color: #c4006a;
}
.button.button-danger {
    border-color: #d63638;
    color: #d63638;
    background: #fff;
}
.button.button-danger:hover {
    background: #d63638;
    color: #fff;
    border-color: #d63638;
}
#drm-shortcode-wrap .button:disabled,
#drm-admin-wrap .button:disabled,
.drm-form .button:disabled {
    border-color: #ccc;
    color: #999;
    background: #f9f9f9;
    cursor: not-allowed;
}
.button.button-small {
    padding: 3px 8px;
    font-size: 0.8em;
}

/* --- 2. Slug Section Layout --- */
.drm-slug-section {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 25px;
    background: #fff;
}
.drm-slug-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}
.drm-slug-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #222;
}
.drm-slug-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.drm-slug-info {
    padding: 15px;
    background: #fdfdfd;
}
.drm-slug-info p {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 0.95em;
}
.drm-slug-info p:last-child {
    margin-bottom: 0;
}
.drm-slug-info p a {
    color: #e10078;
    text-decoration: none;
    font-weight: 500;
}
.drm-slug-info p a:hover {
    text-decoration: underline;
}
.drm-visit-count {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.drm-visit-count span {
    font-size: 0.9em;
}
.drm-added-on {
    font-size: 0.9em;
    color: #555;
}

/* --- 3. Table Styles --- */
.drm-table-container {
    width: 100%;
    overflow-x: auto;
}
.drm-table {
    width: 100%;
    border-collapse: collapse;
}
.drm-table th,
.drm-table td {
    padding: 10px 12px;
    text-align: left;
    border-top: 1px solid #eee;
    vertical-align: middle;
}
.drm-table th {
    font-weight: bold;
    color: #333;
    border-top: none;
    background: #f9f9f9;
    font-size: 0.9em;
}
.drm-table td {
    font-size: 0.95em;
}
.drm-table td:last-child {
    text-align: right;
    white-space: nowrap;
}
.drm-table td:last-child .button {
    margin-left: 5px;
}
.drm-table td[data-label="URL"] {
    overflow-wrap: break-word; /* Fixes long URL wrapping */
    word-break: normal;
    max-width: 250px;
}
.drm-status-active { color: #28a745; font-weight: bold; }
.drm-status-active::before { content: '✔ '; }
.drm-status-inactive { color: #777; }
.drm-added-on-cell {
    font-size: 0.9em;
    color: #555;
    white-space: nowrap;
}

/* --- 4. Forms & Modal --- */
#drm-add-slug-container { padding: 20px; }
.drm-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.drm-form-group {
    display: flex;
    flex-direction: column;
}
.drm-form-group label {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #333;
}
.drm-form-group input[type="text"],
.drm-form-group input[type="url"],
.drm-form-group input[type="number"] {
    width: 100%;
    max-width: 450px;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #b0b0b0;
    font-size: 1em;
}
.drm-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}
.drm-modal.show {
    display: flex;
}
.drm-modal-content {
    background-color: #fefefe;
    padding: 20px 25px;
    border: 1px solid #888;
    width: 95%;
    max-width: 500px;
    border-radius: 4px;
    position: relative;
}
.drm-modal-close {
    color: #aaa;
    position: absolute;
    top: 5px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.drm-modal h2 { margin-top: 0; margin-bottom: 20px; font-size: 1.4em; }

/* --- 5. Shuffle Toggle Switch --- */
.drm-shuffle-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}
.drm-shuffle-toggle-wrap strong {
    font-size: 0.95em;
}
.drm-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}
.drm-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.drm-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}
.drm-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
.drm-toggle-switch input:checked + .drm-toggle-slider {
    background-color: #e10078;
}
.drm-toggle-switch input:checked + .drm-toggle-slider:before {
    transform: translateX(22px);
}
.drm-shuffle-settings {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
}
.drm-shuffle-inputs {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}
.drm-shuffle-inputs .drm-form-group {
    flex: 1;
}
.drm-shuffle-inputs input[type="number"] {
    max-width: none;
    width: 100%;
}

/* --- 6. Mobile Responsive Table --- */
@media (max-width: 782px) {
    .drm-table thead {
        display: none;
    }
    .drm-table tbody, .drm-table tr, .drm-table td {
        display: block;
        width: 100%;
    }
    .drm-table tr {
        border: 1px solid #ddd;
        border-radius: 4px;
        margin-bottom: 15px;
    }
    .drm-table td {
        border: none;
        border-bottom: 1px solid #eee;
        padding-left: 12px;
        padding-right: 12px;
        text-align: right;
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .drm-table td:before {
        content: attr(data-label);
        font-weight: bold;
        text-align: left;
        padding-right: 15px;
        color: #333;
    }
    .drm-table td:last-child {
        text-align: left;
        border-bottom: none;
        padding-top: 15px;
        padding-bottom: 15px;
        display: block;
        white-space: normal;
    }
    .drm-table td[data-label="URL"] {
        word-break: break-all;
    }
    .drm-table td[data-label="Status"] {
        flex-wrap: wrap;
    }
    .drm-added-on-cell {
        font-size: 0.95em; /* Match other cells */
    }
}

/* --- 7. Desktop Table Alignment --- */
@media (min-width: 783px) {
    .drm-table {
        table-layout: fixed;
    }
    .drm-col-label { width: 18%; }
    .drm-col-url { width: 30%; }
    .drm-col-added { width: 17%; }
    .drm-col-status { width: 10%; }
    .drm-col-actions { width: 25%; }
}