* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #121212;
    color: #e0e0e0;
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Back Button */
.back-button-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(18, 18, 18, 0.85);
    margin: -40px -20px 20px;
    padding: 20px 20px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #2d2d2d;
    border: 2px solid #404040;
    border-radius: 8px;
    color: #e0e0e0;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-back:hover {
    background: #3d3d3d;
    border-color: #4CAF50;
    transform: translateX(-5px);
}

/* Header */
.page-header {
    margin-bottom: 50px;
}

.page-header h1 {
    font-family: 'Oswald', sans-serif;
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 10px;
    font-weight: 600;
}

.page-header p {
    color: #9e9e9e;
    font-size: 1.05rem;
}

/* Section Container */
.ads-section {
    background: #1e1e1e;
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #2d2d2d;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.section-title i {
    font-size: 2rem;
    color: #4CAF50;
}

.section-title h2 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    font-weight: 600;
}

.section-subtitle {
    color: #9e9e9e;
    font-size: 0.95rem;
    margin-top: 5px;
}

/* Material Design Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e0e0e0;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #404040;
    transition: 0.3s;
    border-radius: 30px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

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

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

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

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* Material Design Stepper Controls */
.duration-control {
    margin: 30px 0;
    padding: 25px;
    background: #2d2d2d;
    border-radius: 12px;
}

.controls-row {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #e0e0e0;
    font-size: 0.95rem;
    white-space: nowrap;
}

.stepper-control {
    display: flex;
    align-items: center;
    gap: 0;
    background: #1a1a1a;
    border-radius: 10px;
    border: 2px solid #404040;
    overflow: hidden;
    transition: border-color 0.3s;
}

.stepper-control:hover {
    border-color: #4CAF50;
}

.stepper-btn {
    background: #2d2d2d;
    border: none;
    color: #e0e0e0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.stepper-btn:hover {
    background: #3d3d3d;
    color: #4CAF50;
}

.stepper-btn:active {
    background: #4CAF50;
    color: #fff;
    transform: scale(0.95);
}

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

.stepper-value {
    min-width: 80px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #4CAF50;
    padding: 0 20px;
    user-select: none;
    font-family: 'Oswald', sans-serif;
    letter-spacing: 0.5px;
}

.stepper-range {
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* Drag and Drop Zone */
.upload-zone {
    border: 3px dashed #404040;
    border-radius: 12px;
    padding: 50px;
    text-align: center;
    background: #2d2d2d;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 30px;
}

.upload-zone:hover {
    border-color: #4CAF50;
    background: #333;
}

.upload-zone.drag-over {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    transform: scale(1.02);
}

.upload-zone i {
    font-size: 3rem;
    color: #4CAF50;
    margin-bottom: 20px;
}

.upload-zone h3 {
    font-size: 1.3rem;
    color: #e0e0e0;
    margin-bottom: 10px;
    font-weight: 600;
}

.upload-zone p {
    color: #9e9e9e;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.upload-zone .requirements {
    color: #666;
    font-size: 0.85rem;
    margin-top: 15px;
}

.upload-zone input[type="file"] {
    display: none;
}

/* Ad Grid */
.ads-grid {
    display: grid;
    gap: 20px;
    margin-top: 30px;
}

/* Web ads grid - 2 columns for 728x90 */
#webAdsGrid {
    grid-template-columns: repeat(2, 1fr);
}

/* Phone ads grid - 3 columns for 320x50 */
#phoneAdsGrid {
    grid-template-columns: repeat(3, 1fr);
}

/* Tablet ads grid - 2 columns for 728x90 */
#tabletAdsGrid {
    grid-template-columns: repeat(2, 1fr);
}

.ad-item {
    background: #2d2d2d;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: move;
    position: relative;
}

.ad-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.ad-item.sortable-ghost {
    opacity: 0.4;
}

.ad-item.sortable-drag {
    opacity: 0.8;
}

.ad-image-container {
    position: relative;
    background: #1a1a1a;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-image-container img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #e0e0e0;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.delete-btn:hover {
    background: rgba(244, 67, 54, 0.8);
    border-color: #f44336;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.ad-info {
    padding: 15px;
}

.ad-info .ad-id {
    font-size: 0.8rem;
    color: #666;
    font-family: 'Courier New', monospace;
}

.ad-info .ad-date {
    font-size: 0.85rem;
    color: #9e9e9e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ad-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 5px;
}

/* Individual Ad Toggle Switch (smaller version) */
.ad-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ad-toggle-switch {
    position: relative;
    width: 44px;
    height: 22px;
}

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

.ad-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #404040;
    transition: 0.3s;
    border-radius: 22px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

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

.ad-toggle-switch input:checked + .ad-toggle-slider {
    background-color: #4CAF50;
}

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

.ad-toggle-switch input:focus + .ad-toggle-slider {
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.ad-toggle-switch input:disabled + .ad-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.ad-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.ad-info .ad-dimensions {
    font-size: 0.85rem;
    color: #4CAF50;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-url-compact {
    background: #2d2d2d;
    border: 2px solid #404040;
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-url-compact:hover {
    background: #3d3d3d;
    border-color: #4CAF50;
    transform: translateY(-2px);
}

.url-modal-input {
    width: 100%;
    background: #1a1a1a;
    border: 2px solid #404040;
    color: #e0e0e0;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    margin-top: 15px;
    transition: border-color 0.3s;
}

.url-modal-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.url-modal-input::placeholder {
    color: #666;
}

.drag-handle {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Device Sections */
.device-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #2d2d2d;
}

.device-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.device-header i {
    font-size: 1.5rem;
    color: #4CAF50;
}

.device-header h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1.3rem;
    color: #e0e0e0;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #9e9e9e;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Preview Section */
.preview-section {
    background: #2d2d2d;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.preview-header i {
    color: #4CAF50;
    font-size: 1.2rem;
}

.preview-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e0e0e0;
}

.preview-container {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    position: relative;
    overflow: hidden;
}

.preview-ad {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    /* Transition duration set dynamically by JavaScript */
}

.preview-ad.active {
    opacity: 1;
    pointer-events: auto;
}

.preview-ad a {
    display: block;
    cursor: pointer;
}

.preview-ad img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

.preview-placeholder {
    color: #666;
    text-align: center;
}

.preview-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #2d2d2d;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s;
}

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

.modal-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.modal-header i {
    font-size: 2rem;
}

.modal-header.error i {
    color: #f44336;
}

.modal-header.warning i {
    color: #FF9800;
}

.modal-header h3 {
    font-size: 1.5rem;
    color: #fff;
    font-weight: 600;
}

.modal-body {
    color: #e0e0e0;
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 30px;
}

.modal-body strong {
    color: #4CAF50;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: #4CAF50;
    color: #fff;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-danger {
    background: #f44336;
    color: #fff;
}

.btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.btn-secondary {
    background: #404040;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #505050;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Feed URL Box */
.feed-url-box {
    background: #2d2d2d;
    padding: 20px;
    border-radius: 12px;
    margin-top: 30px;
}

.feed-url-box label {
    display: block;
    font-size: 0.9rem;
    color: #9e9e9e;
    margin-bottom: 15px;
    font-weight: 600;
}

.feed-url-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #1a1a1a;
    border: 2px solid #404040;
    color: #4CAF50;
    padding: 14px 20px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
}

.feed-url-link:hover {
    background: #252525;
    border-color: #4CAF50;
    color: #5ed662;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.feed-url-link i {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.feed-url-link:hover i {
    transform: translateX(3px);
}

/* Responsive */
@media (max-width: 768px) {
    .ads-section {
        padding: 25px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .ads-grid {
        grid-template-columns: 1fr;
    }

    .duration-control {
        padding: 20px;
    }

    .controls-row {
        flex-direction: column;
        gap: 20px;
    }

    #webAdsGrid,
    #phoneAdsGrid,
    #tabletAdsGrid {
        grid-template-columns: 1fr;
    }
}
